Is it possible to make approval comments mandatory? There is one discussed here. http://christopheralunlewis.blogspot.in/2012/09/making-rejection-comments-mandatory-in.html

I've a two step approval process but I don't get comments in my trigger(pi.Steps[0].Comments).

Am I missing something here?

  • 1
    Can you post up some of your code? It might help us work out what the problem is
    – Jon Hazan
    Sep 28, 2012 at 10:17
  • It is the same as explained in the blog post except that I don't get the second step(first step is submission). I've written the trigger on an object(before update) - field update on approval. Will update the question with piece of code. Sep 28, 2012 at 16:12
  • Can you check if it works fine when you enter comments and reject the record. The problem I face is that the recent comments is not available when I query it inside the trigger.
    – user651
    Oct 1, 2012 at 5:19
  • When i try to reject the record i got an error message. System.ListException: List index out of bounds: 0: Trigger.NPI_RequireRejectionComment: line 38, column 1". 38 if ((pi.Steps[0].Comments == null || pi.Steps[0].Comments.trim().length() == 0)) {
    – user2259
    Jan 22, 2013 at 4:47

2 Answers 2


Thanks for looking at my blog post.

From looking at your question, may I ask first, are you looking to make comments mandatory for approvals, rejections or both? In my example I only make comments mandatory on rejections. If you are looking to do this for approvals or both, then you would need to adjust the trigger code accordingly, including altering the SOQL query so it looks at approval messages for comments as well.

The fact that the approval process is a two step is not important, as the final rejection and approval methods fire the trigger. I just tested it out on a two step process and it worked as intended.

I hope that helps! If not please post your code with a bit more info and I will see how I can help.

Update 8/10/2012: I have an updated version of my mandatory comments technique that accounts for all steps in an approval steps in a process. I have written a blog post that explains how to do this.

  • Yes. As you said, trigger fires only on final step. I want to mandate comments for every step. Is it possible? Oct 2, 2012 at 17:10
  • Hello Vignesh, I've done a little bit more research into this, and I do believe it is possible using a twice executed trigger and a workflow rule. I'm in the process of confirming my theory. Watch this space I hope to be posting a new blog post containing the details within the next few days! Oct 4, 2012 at 16:56
  • Is this solution still relevant 10 years later ? Is there no simpler alternative approach now ?
    – zakinster
    Apr 1, 2022 at 13:01

I see the code working fine!!!

I tried to do the same from the demo and when I tried to reject a record i got the following error : Validation Errors While Saving Record(s) 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!".

Some assumptions(could be silly) 1) Did you activate the approval process,if so check in the dev console to see if the entry criteria is evaluating to true. 2) You modified the trigger to point to the right custom object(some people do the workbook exercise in their dev org and the invoice object is on of the objects, just an assumption) 3) Did you do three workflow updates 1) approval update 2) pending update 3) rejection update?

These are some of the points I missed hopefully this is one of them you missed too. As for the code thanks for the link,another keep safe code :). works beautiful.

  • As christopher said, the trigger fires only on final approval/rejection. Oct 2, 2012 at 17:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .