Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let splittedURL = salesforceUrl.split('/');
- let lastItem = splittedURL[splittedURL.length - 1];
- let prelastItem = splittedURL[splittedURL.length - 2];
- let id = lastItem === "view" ? prelastItem : lastItem;
- id = id.includes('?') ? id.substr(0, id.indexOf('?')) : id;
- //get oppurtutnities from salesforce and find Contract_Status__c field from there
- CachedOpportunity.query(function (opportunities) {
- let found = false;
- for(let i=0; i<opportunities.length; i++){
- let opp = opportunities[i];
- let minIdLength = Math.min(opp.Id.length, id.length);
- if (opp.Id.substring(0, minIdLength) === id.substring(0, minIdLength)) { //ID in opportunity has postfix of 3 chars
- if (opp.Contract_State__c) paperwork = opp.Contract_State__c;
- found = true;
- break;
- }
- }
- if (!found) {
- console.log("Paperwork status of item with ID not found:" + id);
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement