• Vimal D
  • NEWBIE
  • 20 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 4
    Replies
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;
    }
created a custom object and created a Approval process for records that enter a certain criteria in that object. I have assigned a custom Visual Force Email Template to the Approval process. And based on the approval or rejection a field is updated appropriately. While testing I was not able to approve the record, the steps that I followed are

    Create a new record based on the criteria
    Click on the Submit for Approval button
    I received email in the customer email template that I assigned in the user email address who will approve the record
    I replied to the email with "Approve" in the first line (the reply went to something@something.wrkfl.salesforce.com)
    There are no errors received but still record is still not approved.

could you please help
I am getting the below error while redirecting to VF page while selecting the new record type when i click continue

An internal server error has occurred
An error has occurred while processing your request. The salesforce.com support team has been notified of the problem. If you believe you have additional information that may be of help in reproducing or correcting the error, please contact Salesforce Support. Please indicate the URL of the page you were requesting, any error id shown on this page as well as any other related information. We apologize for the inconvenience.

Thank you again for your patience and assistance. And thanks for using salesforce.com!

Error ID: 608742340-43136 (-1373969722)

apex page and apex class used
<apex:page standardController="Agreement__c" extensions="DispatcherContactNewController"  action="{!pageredir}" showHeader="false" sidebar="false" cache="true" expires="50" >     
This is my new test page
</apex:page>


public with sharing class CustomAgreement {
    public String home {get;set;}
      
    public Pagereference pageredir()
    {
        home= 'CustomAgreement';
        if(home==null)
            return null;          
            Pagereference newpage = new Pagereference ('/apex/'+home);
            return newpage;
            }   
}
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;
    }
I am getting the below error while redirecting to VF page while selecting the new record type when i click continue

An internal server error has occurred
An error has occurred while processing your request. The salesforce.com support team has been notified of the problem. If you believe you have additional information that may be of help in reproducing or correcting the error, please contact Salesforce Support. Please indicate the URL of the page you were requesting, any error id shown on this page as well as any other related information. We apologize for the inconvenience.

Thank you again for your patience and assistance. And thanks for using salesforce.com!

Error ID: 608742340-43136 (-1373969722)

apex page and apex class used
<apex:page standardController="Agreement__c" extensions="DispatcherContactNewController"  action="{!pageredir}" showHeader="false" sidebar="false" cache="true" expires="50" >     
This is my new test page
</apex:page>


public with sharing class CustomAgreement {
    public String home {get;set;}
      
    public Pagereference pageredir()
    {
        home= 'CustomAgreement';
        if(home==null)
            return null;          
            Pagereference newpage = new Pagereference ('/apex/'+home);
            return newpage;
            }   
}