You need to sign in to do that
Don't have an account?
d.tejdeep@nicomatic.in
I want to combine two button as one button
Visualforcepage:
Apex Coding:
What i am doing .I am updating in the save button and http post is done in the second button.
I have tried to update it on post method but it is not taking .
I want to use only one button for these two actions .How can i do it
<apex:commandButton value="CLICK TO CREATE ORDER" action="{!post}" disabled="{!hide}" >
<apex:commandButton onclick="insert_numbers()" action="{!save}" value="Insert Numbers and Save" rerender="mytable" />
Apex Coding:
public PageReference save() { update ob; refreshPage=true; return null; } public void post(){ HttpRequest req = new HttpRequest(); HttpResponse res = new HttpResponse(); Http http = new Http(); req.setMethod('POST' ); // Method Type
What i am doing .I am updating in the save button and http post is done in the second button.
I have tried to update it on post method but it is not taking .
I want to use only one button for these two actions .How can i do it
you cannot do a callout after doing a DML (your update).
You can do something like this:
Basically you are doing the update in the save method (the only action of your single button in the page), and then executin a future method (that can do a callout) passing in your object id (if it is not needed the method can have no parameters on it: future calls must be static and can only have simple types on its signature, so no SObject can be passed).
This way you will only use 1 method to do both things.
All Answers
you cannot do a callout after doing a DML (your update).
You can do something like this:
Basically you are doing the update in the save method (the only action of your single button in the page), and then executin a future method (that can do a callout) passing in your object id (if it is not needed the method can have no parameters on it: future calls must be static and can only have simple types on its signature, so no SObject can be passed).
This way you will only use 1 method to do both things.