You need to sign in to do that
Don't have an account?
Vimal D
user should not click submit for approval button twice
Hi,
Users are receiving an error while tried to click "submit for Approval button in Visualforce page. I am not able to redirect the below error into a custom message. could you please help. Below is the submit for approval code.
Process failed. First exception on row 0; first error: ALREADY_IN_PROCESS, Cannot submit object already in process.: []
Error is in expression '{!submit_for_approval}' in component <apex:commandButton> in page customagreementedit: Class.Agreement_Edit_AC.submit_for_approval: line 72, column 1
An unexpected error has occurred. Your development organization has been notified.
submit for approval code
public PageReference submit_for_approval() {
Id id = ApexPages.currentPage().getParameters().get('id');
Approval.ProcessSubmitRequest req1=new Approval.ProcessSubmitRequest();
req1.setComments('Submitting request for approval.');
//req1.setNextApproverIds(new Id[]{UserInfo.getUserId()});
req1.setObjectId(id);
Approval.ProcessResult result = Approval.process(req1);
if(result.isSuccess())
{
ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.CONFIRM,'Approval flow submitted successfully'));
}
else {
ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR,'SubmissionFailed as the contract not in Submitted Status'));
}
return null;
}
Users are receiving an error while tried to click "submit for Approval button in Visualforce page. I am not able to redirect the below error into a custom message. could you please help. Below is the submit for approval code.
Process failed. First exception on row 0; first error: ALREADY_IN_PROCESS, Cannot submit object already in process.: []
Error is in expression '{!submit_for_approval}' in component <apex:commandButton> in page customagreementedit: Class.Agreement_Edit_AC.submit_for_approval: line 72, column 1
An unexpected error has occurred. Your development organization has been notified.
submit for approval code
public PageReference submit_for_approval() {
Id id = ApexPages.currentPage().getParameters().get('id');
Approval.ProcessSubmitRequest req1=new Approval.ProcessSubmitRequest();
req1.setComments('Submitting request for approval.');
//req1.setNextApproverIds(new Id[]{UserInfo.getUserId()});
req1.setObjectId(id);
Approval.ProcessResult result = Approval.process(req1);
if(result.isSuccess())
{
ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.CONFIRM,'Approval flow submitted successfully'));
}
else {
ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR,'SubmissionFailed as the contract not in Submitted Status'));
}
return null;
}
If the record is already is submited for approval than this kind of problem occur.
You can use try and catch block to handle this
And you can also get the status of record that is it already in process or not ? Below code helps you to get the status of currrent record
IF it helps you than please mark it as a solution and ENJOY APEX
All Answers
is the bold value below correctly written?I think it should be Agreement_Edit__c.Tell me if it is correct.
Class.Agreement_Edit_AC.submit_for_approval: line 72, column 1
Regards
Nitesh
Yes it is the apex class name and it is correct.
If the record is already is submited for approval than this kind of problem occur.
You can use try and catch block to handle this
And you can also get the status of record that is it already in process or not ? Below code helps you to get the status of currrent record
IF it helps you than please mark it as a solution and ENJOY APEX