Thursday, May 16, 2013

How To Stop People From Making Comments On Closed Cases

Sometimes people ask me how they can make closed cases "uncommentable" -- once those cases are closed, they don't want their reps to be able to make new comments on them. Traditionally the way to accomplish this would be to change the record type of closed cases and use a layout for that record type which hides the Case Comments related list.

This is not ideal, though, because it means that you can't read the comments either.  Fortunately, with Workflow From Case Comments, there is a better way.  As I mentioned in my previous blog entry, Workflow From Case Comments is a "chaining" workflow, which means that when it edits the parent case, it kicks off the workflow anew on that case object.  We can use this to our advantage in solving this problem.  Here's how.

  1. Define a checkbox-type custom field on Case called "No more comments." Do not add it to any of the Case page layouts.
  2. Make a validation rule which shows the error "You cannot add comments to a closed case" at the top of the page.  In the formula section put simply "No_more_comments__c=true". 
  3. Make a Workflow on the Case Comments object which fires when Case: Closed equals True.
  4. Make a Field Update in that workflow which sets the No More Comments field to true. 
  5. Activate the workflow rule!
Now, when you try to submit a comment on a closed case, the workflow will fire on the case comment.  This will make the modification to the No More Comments field on the Case to set it to true, which will violate the validation rule and disallow the save, showing the error "You cannot add comments to a closed case."

Workflow From Case Comments to the rescue!

2 comments:

  1. Awesome post, exactly what I needed. Thank you!!!

    ReplyDelete
  2. Why wouldn't you check / uncheck the No More Comments when the case closes instead of firing on every attempt at a comment? It seems like less resources to do it once.

    ReplyDelete