You need to sign in to do that
Don't have an account?
David Bloomy Bloom
Need help on apex trigger to perform http call once the state of field changes to TRUE
Hi, I am trying to execute the below when I change the status of First_Email_Sent__c from False to True. When this changes I need to fire an http request. Below is what I have managed to find but I am unsure how to check the status has changed and if the http request is correct.
Thanks in advance
David
trigger Run_custom_button on Sabre_Hotels__c (after update) {
if record.First_Email_Sent__c == true {
url = "https://composer.congamerge.com
?sessionId={!API.Session_ID}
&serverUrl={!API.Partner_Server_URL_290}
&id={!Sabre_Hotels__c.Id}
&ReportId=00O900000079wd3?pv0={!Sabre_Hotels__c.Name}
&EmailToID=0039000000B4Z9N
&EmailAdditionalTo={!Sabre_Hotels__c.Hotel_Email_Address__c}
&CETID=a0J9000000U4NUn
&TemplateId=a0L9000000DB1Te
&AC0=1
&SC0=1
&_DS7=9
&DS7=1
&QMode=3";
HttpRequest req = new HttpRequest();
req.setEndpoint(url);
req.setMethod('GET');
Http http = new Http();
HTTPResponse res = http.send(req);
}
}
Thanks in advance
David
trigger Run_custom_button on Sabre_Hotels__c (after update) {
if record.First_Email_Sent__c == true {
url = "https://composer.congamerge.com
?sessionId={!API.Session_ID}
&serverUrl={!API.Partner_Server_URL_290}
&id={!Sabre_Hotels__c.Id}
&ReportId=00O900000079wd3?pv0={!Sabre_Hotels__c.Name}
&EmailToID=0039000000B4Z9N
&EmailAdditionalTo={!Sabre_Hotels__c.Hotel_Email_Address__c}
&CETID=a0J9000000U4NUn
&TemplateId=a0L9000000DB1Te
&AC0=1
&SC0=1
&_DS7=9
&DS7=1
&QMode=3";
HttpRequest req = new HttpRequest();
req.setEndpoint(url);
req.setMethod('GET');
Http http = new Http();
HTTPResponse res = http.send(req);
}
}
It is recommended to do callouts in future methods while working with triggers.
This link http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_classes_annotation_future.htm?SearchType=Stem&Highlight=future|Future (http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_classes_annotation_future.htm?SearchType=Stem&Highlight=future|Future) might help you.
If this answers your question, mark this as best answer.
Thanks,
N.J
are you able to advise?
thanks
David