+ Start a Discussion
David Bloomy BloomDavid Bloomy Bloom 

apex trigger execute a custom button when a field changes from False to True

Hi, I am looking for assistance to write an apex trigger to execute a cusom button on my custom object when I change the state of a check box (via apex loader) from false to true.

My custom field is First_Email_Sent__c and my custom button is Conga_First_Email My custom object is called Sabre_Hotels (Sabre_Hotels__c)

thanks you in advance for any assistance.

David
Best Answer chosen by David Bloomy Bloom
vmanumachu1.393650924860069E12vmanumachu1.393650924860069E12
Hi David,

The above URL is launching an email composer. Unfortunaltely, this is not possible using apex triggers. Apex triggers are not interactive in nature and hence the above functionality cannot be achieved using triggers. Also, going by your requirement, you are setting a checkbox to true or false from a dataloader, so i assume it will be bulk data processing, so i dont think its realistic to open email composers for all the records.

You can use triggers if you want to send automated emails to if you conditions are met.

All Answers

vmanumachu1.393650924860069E12vmanumachu1.393650924860069E12
I dont think you can execute a custom button from an Apex trigger. You can instead embed the same logic the custom button executes into the apex trigger and execute.

Hope this clarifies.

Please mark it as best answer if it answers your question. It helps others.
David Bloomy BloomDavid Bloomy Bloom
Hi vmanumachu1.393650924860069E12 thanks for the quick reply. I can easily copy the logic from the custom button into the apex trigger but I have never written an apex trigger and am looking for guidance on how to create the trigger code. Are you able to assist with the basics?

Here is the code from the custom button:

https://composer.congamerge.com

?sessionId={!API.Session_ID}

&serverUrl={!API.Partner_Server_URL_290}

&id={!Sabre_Hotels__c.Id}

&ReportId=00O9000000793dm?pv0={!Sabre_Hotels__c.Name}

&EmailToID=0039000000B4Z9N

&EmailAdditionalTo={!Sabre_Hotels__c.Hotel_Email_Address__c}

&CETID=a0J9000000U4KIK

&TemplateId=a0L9000000DB1Te

&AC0=1

&SC0=1

&_DS7=9

&DS7=1

&QMode=3
vmanumachu1.393650924860069E12vmanumachu1.393650924860069E12
Hi David,

The above URL is launching an email composer. Unfortunaltely, this is not possible using apex triggers. Apex triggers are not interactive in nature and hence the above functionality cannot be achieved using triggers. Also, going by your requirement, you are setting a checkbox to true or false from a dataloader, so i assume it will be bulk data processing, so i dont think its realistic to open email composers for all the records.

You can use triggers if you want to send automated emails to if you conditions are met.
This was selected as the best answer
David Bloomy BloomDavid Bloomy Bloom
Thanks again, I will speak to the company that provide the custom button and see if they have a process that can execute without a URL launcher.

David