function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
IS Admin 7IS Admin 7 

"We need to confirm that your request is valid. Please repeat your last action" error when using button executing Javascript for Approval Process submission

Can we replace the following code:
redirectPage = new PageReference(String.format('/p/process/Submit?retURL=%2F{0}&id={0}', new String[] {sObjId}));

with:

Approval.ProcessSubmitRequest approvalRequest = new Approval.ProcessSubmitRequest();

approvalRequest.setObjectId(sObjId);

Approval.ProcessResult approvalResult = Approval.process(approvalRequest);

if (!approvalResult.isSuccess())
{
ApexPages.Message error = new ApexPages.Message(ApexPages.Severity.ERROR, 'There was an error with the Submit For Approval Request.');
ApexPages.addMessage(error);
}
redirectPage =new PageReference(String.format('/{0}', new String[] {sObjId}));
redirectPage.setRedirect(true);

}
AshlekhAshlekh
Hi, 

Salesforce has restriceted to send a record for approval in this way (Url passing).

This is an intentional change as part of Winter 16 release, to over come this you may need to use REST API to submit the approval or use apex code

https://help.salesforce.com/apex/HTViewSolution?id=000229821&language=en_US

http://salesforce.stackexchange.com/questions/94697/winter-16-problem-with-navigatetourl-p-process-submit

-Thanks
Ashlekh Gera