+ Start a Discussion

Invoke VF page when Submit for Approval is clicked

I have an approval process for the Quotes. We have some entry criteria that need to be met before the quotes can be submitted for approval.


Right now, when the criteria is not met, we get a standard Salesforce error "This record does not meet the entry criteria or initial submitters of any active approval processes. Please contact your administrator for assistance. "


I would like to let the users know exactly which criteria was not met . This can be done in two ways, either invoke a VF page when the criteria is not met or send an email alert to the user.


I want to implement the first option, where we have a custom error  VF page, telling the user exactly what went wrong. If this cannot be done then I will go with the email alert.


With first option, I have not figured out where to invoke the custom VF page from. Submit for Approval button is not visible and hence I cannot invoke it from there. Has anyone implemented this kind of functionality? Help Please!!!




I don't think "Submit for Approval" action can return that elaborate error message which can help in narrowing down to specific entry criteria not being met.


So one approach could be to - check the input criteria within APEX Code itself (entry to Approval process is through a Visualforce page), and provide an option for "Submit for Approval" only when you know that criteria has been met, else you can raise a warning to User from your Apex code.


Once you establish that input criteria is being met, Show the button "Submit for Approval" on click of this button, you can Submit the record for Approval using APEX approval classes.


Since I don't know exact flow of your application, I can't describe the exact hooks of how to integrate, what is suggested above, into your requirement.


But above is definitely an approach to address your requirement of informing User what specific conditions did not meet for the approval to begin.