You need to sign in to do that
Don't have an account?
Raj R.
How to create a button that calls apex calls that does future callout?
Hi,
We have a need to create a button that on click will take the current Opportunity data (some fields) and pass it into the apex class (that is a future callout) so it can execute the logic in the class.
How would i do this?
We have a need to create a button that on click will take the current Opportunity data (some fields) and pass it into the apex class (that is a future callout) so it can execute the logic in the class.
How would i do this?
//class that does future callout to some endpoint class Sample { @future(callout=true) public sendCallOut() { //some action using the current opportunity HttpRequest req = new HttpRequest(); //add the appropriate headers ///put opportunity data in the body of request HTTPResponse resp = new HTTPResponse(); //send and process request }//end sendCallOut() }//end Sample
To do this I'd create a custom controller APEX class, put the method in that, then create a Visualforce page with nothing in it and call the method from the controller.
I'd then create a custom URL button that called that visualforce page with the record Id appended to the URL so it could be passed into the controller and used referenced in the call out method
I havent tested the below but something like:-
controller:-
visualforce page called myPage
the button - create one that directs to a URL
enter this url /apex/myPage?thisOppId={!OpportunityId}
add to opportunity page layout
Hope this helps you get started
If this solves your question please mark as best answer to help others.