function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
David Bloomy BloomDavid 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);
    }
}
Nilesh Jagtap (NJ)Nilesh Jagtap (NJ)
Hi David,

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
David Bloomy BloomDavid Bloomy Bloom
Hi NJ, I appreciate your guidance, but I am very new to apex triggers and am looking for some assistance with the actual code

are you able to advise?

thanks
David