You need to sign in to do that
Don't have an account?
RajanJasuja
How to make Approval comment required
Hi,
I have two questions related with Approvals.
1. Is their a way to make Approver comments required while approving or rejecting any record?
2. How can we make any field required on record while some one is approving or rejecting the record?
Cheers!
Rajan
Validate if
1.Status=Approved || Rejected, AND
2. ISCHANGED(Commnent)
Returns TRUE
Hi,
Thanks for your reply.
You can write a trigger on the approval process. Approval step will make a 'field update' that will trigger a before update trigger.
Check for the comment, if field is empty, add a addError to the object. It will stop the approval process and add a error.
It works beautifully.
BeeddiskShah is right, this is the method I adopted to make this possible.
For a step by step guide on how to do this, check out my blog posts:
Making rejection comments mandatory (Simple version, only deals with rejection comments)
and
Making all approval comments mandatory (More complex, but covers all scenarios).
Navigate to the field updates menu (Setup --> App Setup --> Create --> Workflows & Approvals --> Field Updates) and create a new field update worfkflow action. Set the name of the new action to "Approval Status Pending" and unique name to "Approval_Status_Pending" and object to the object you added the custom field to. Then select the Approval Status field from the resulting drop down. In the new field value options, select "A specific value" then pick "Pending" status.
Hi,
Below is the error when i tried to tetx the approval process:
There were custom validation error(s) encountered while saving the affected record(s). The first validation error encountered was "Apex trigger RequireRejectionComment caused an unexpected exception, contact your administrator: RequireRejectionComment: execution of BeforeUpdate caused by: System.ListException: List index out of bounds: 0: Trigger.RequireRejectionComment: line 42, column 1".
Hi Sol,
My first thought would be that this error message is being generated by the following line
"if ((pi.Steps[0].Comments == null || pi.Steps[0].Comments.trim().length() == 0))"
The error message seems to suggest that the pi.Steps collection is empty. Just a few quick questions:
1) Have you followed all of the other instructions in the blog post, set up the approval processes etc. ?
2) If so, are you changing the value of the Approval_Status__c as part of any other process outside the main approval?
Hi Christopher, I followed all the instructions in the blog. I make a picklist field with the picklist values, Approved, Rejected and Pending. I added the 3 fields update in the Approval process then copied the code changing the custom object I use. I think that's all the process in the Blog.
I am also getting the same error..can some one help please?
The problem here is pi.Steps[0] is null is Your Rejection Process going back a step?
Have spent a few hours rewriting the code trying to make this work.
Currently I see major issue with this solution: if your Approval Step Rejection does not go to Final Rejection Step. ( i.e. you go back a step )
-- The processInstanceStep for that rejection is not inserted within the context of the current trigger. So you can determine if a comment had been entered and hence you always fail validation when trying to reject an approval.
Here is my updated method if you want to try this.
I've been getting this error message,
" There were custom validation error(s) encountered while saving the affected record(s). The first validation error encountered was "Operation Cancelled: Please provide a rejection reason!".
Choose another list to continue.
"
could i get your kind guidance and help?