You need to sign in to do that
Don't have an account?
sindhu@demo.com
How to execute the trigger on click of a custom button
Hi, I have written a trigger and is perfectly fine.I want this trigger to be executed when clicked on a custom button in Case object. Can anyone help me out with this??
You can refer to this cookbook on how to call classes using javascript
http://developer.force.com/cookbook/recipe/creating-a-button-with-apex
Or you can call a vf page action on click of the button.
I would prefer the VF route, gives more control.
All Answers
Hello Siddhu,
you need to update any field on the button clink. Because trigger will fire only when any DML operation will happen. Please marked as solved if it hepls you :)
Trigger is executed only when the Object is updated/deleted. If there is no change in the Object then i think the trigger won't be called.
What i would do is transfer the Trigger Logic inside a separate Apex Class file, then call that Apex Class in both the Trigger and upon click of the Custom Button. Hope this helps!
You can refer to this cookbook on how to call classes using javascript
http://developer.force.com/cookbook/recipe/creating-a-button-with-apex
Or you can call a vf page action on click of the button.
I would prefer the VF route, gives more control.
{!requireScript("/soap/ajax/26.0/connection.js")}
var account = new sforce.SObject("case");
case.id = ("{!case.Id}")
case.reminder__c = true;
sforce.connection.update([case);
window.location.reload();
After that, You may execute trigger on After Update (checking if(reminder__c == true) ..
Thanks & Regards
Rahul Sethi