I had created a simple custom button to submit a custom object to an Approval process with a URL:
<a role="button"
class="btn"
style="text-decoration:none;background:#99C299; font-size:16pt; font-family:arial;"
href = "/p/process/Submit?id={!DS.Id}&retURL=%2F{!DS.Id}"
target = "_self">
<b>Submit For Final Approval</b>
</a>
I now get the error message "We need to confirm that your request is valid. Please repeat your last action." whenever I click the button. It seems as though Salesforce disabled the ability to use the standard URL in my button.
I now tried creating a custom controller with a method to create the approval through Apex:
public class DSReviewController {
public Deal_Summary__c myDS;
public DSReviewController(ApexPages.StandardController stdController){
this.myDS = (Deal_Summary__c)stdController.getRecord();
}
public void approve() {
// Create an approval request for the Deal Summary
Approval.ProcessSubmitRequest approve1 = new Approval.ProcessSubmitRequest();
approve1.setComments('Submitting request for approval.');
approve1.setObjectId(myDS.id);
Approval.ProcessResult result = Approval.process(approve1);
}
}
And I changed my custom button in my VF pages to:
<apex:commandButton action="{!approve}" styleClass="buttonStyle" style="background:#99C299; font-size:16pt; font-family:arial;" value="Submit for Approval"/>
However, when I click the button, nothing happens. Can anyone help?