Ticker

6/recent/ticker-posts

Header Ads Widget

How to check for Permission Sets in Validation Rule



Recently while dealing with one of the requirement for my current project, I need to check for logged in user's persona and based on that, write validation rules which will restrict them to do some operations.

Here is the requirement

Let's say we have two personas - Change User and Change Manager. Both Change User and Change Manager can view and edit the cases, but when the case is in "In Progress" state, Change User is not allowed to update the target resolution date on the case.

Setup

Both the personas - Change User and Change Manager share the same role in the role hierarchy. (I know realistically they should have different role, but in my scenario, this is what customer wants as it aligns with their organization structure). So the way to differentiate them is through permission set. As a result, I have created two permission sets - Change User and Change Manager. Assigned the permission sets to respective users. 

"In Progress" is a case status value and Target resolution date is a custom field on Case object.

Problem faced

To implement the requirement that "Change User is not allowed to update the target resolution date on the case when the case is in In Progress state", I need to write validation rule. But there is no way that you can check for logged in user's assigned permission set in validation rule. There is a Salesforce Idea open for this feature. So makes sense that you vote for this idea.


Solution

I have created two Custom Permissions - Change User and Change Manager. Yes with the same name, but name doesn't matter, I choose to give the same name to make life simpler. 😊Then I added these custom permissions into the corresponding permission sets like Change User ( Custom Permission ) will go into  Change User ( Permission Set) and Change Manager ( Custom Permission ) will go into  Change Manager ( Permission Set).

With that done, I referred these custom permissions in my validation rule ( Yes, we can refer custom permissions in Validation Rule) like below -


I hope this will help you if you are also facing the same problem. I am very much interested to know if you have some other cool tricks to handle this situation. Thank you.

Post a Comment

1 Comments

  1. Thank you, Sudipta, I wasn't aware of this approach!

    ReplyDelete