You need to sign in to do that
Don't have an account?

Calling @FutureCallout Apex Class Via custom button on Leads
I created a custom Java Script button on Lead Object. Should I call a @InvocableMethod Apex class or a futurecallout apex class and pass the Lead ID to the class to further process ?
i am calling futurecall out class with invokeable method using that in a Flow and its working perfectly. Just want to use a custom button too.
This is the code:
{!REQUIRESCRIPT("/soap/ajax/35.0/connection.js")} {!REQUIRESCRIPT("/soap/ajax/35.0/apex.js")} var result = sforce.apex.execute("Futurecallout","ApexWSclass", {Id:'{!Lead.Id}'}, {Email:'{!Lead.Email}'}, {Firstname:'{!Lead.FirstName}'}, ); alert(result); window.location.reload();
i am calling futurecall out class with invokeable method using that in a Flow and its working perfectly. Just want to use a custom button too.
This is the code:
{!REQUIRESCRIPT("/soap/ajax/35.0/connection.js")} {!REQUIRESCRIPT("/soap/ajax/35.0/apex.js")} var result = sforce.apex.execute("Futurecallout","ApexWSclass", {Id:'{!Lead.Id}'}, {Email:'{!Lead.Email}'}, {Firstname:'{!Lead.FirstName}'}, ); alert(result); window.location.reload();
If you want to take the javascript invocation route, then it should have to be a web service method.
The other way to do it is via a VF Page and Custom Controller.
Please find the sample code below for your reference:
Please let us know if it helps.
Best Regards,
Nagendra.P