Last active
March 3, 2020 00:25
-
-
Save iamsonal/d5ed44ca4dea45ee6f7002cb361be703 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// AccountAfterUpdate.trigger | |
trigger AccountAfterUpdate on Account (after update) { | |
if (!Territory2Controller.inFutureContext) { | |
List<Id> accountIds = new List<Id>(); | |
for (Account acc : Trigger.new) { | |
accountIds.add(acc.Id); | |
} | |
Territory2Controller.runTerritoryRules(accountIds, UserInfo.getSessionId()); | |
} | |
} | |
// Territory2Controller.cls | |
public with sharing class Territory2Controller { | |
public static boolean inFutureContext = false; | |
@Future(Callout=true) | |
public static void runTerritoryRules(List<Id> accountIds, String sessionId) { | |
Territory2Controller.inFutureContext = true; | |
List<String> accountTags = new List<String>(); | |
String accountTag = ''; | |
String requestTemplate = ''; | |
... | |
... | |
... | |
HttpRequest request = new HttpRequest(); | |
String urlString = System.Url.getSalesforceBaseUrl().toExternalForm() | |
+ '/services/Soap/u/43.0/' + UserInfo.getOrganizationId(); | |
request.setEndpoint(urlString); | |
request.setMethod('POST'); | |
request.setHeader('Content-Type', 'text/xml'); | |
request.setBody(requestTemplate); | |
String s = String.valueOf(new Http().send(request).getBody()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment