How To

Using Custom Permissions in Process Builder

You may have a need to provide certain users access to a custom process while everyone else follows a common process. This access grouping may apply to a couple of profiles and/or a subset of users.

Here’s where custom permissions comes into play…

Custom permissions allow you to define access checks that can be assigned to users via permission sets or profiles, similar to how you assign user permissions and other access settings. For example, you can define access checks in Apex that make a button on a Visualforce page available only if a user has the appropriate custom permission. Or, you can use them in process builder as in our case.

We will create a custom permission and add this custom permission to a profile and/or permission set that will give users permission to the custom process.

Business Use Case: Addison Dogster is a system administrator at Universal Container. Sammy Sunshine is the Sales Director. He’s requested that when users in the Power Users profile and selected managers will follow a custom process when an opportunity’s stage is updated to “closed won.” If the other users update an opportunity’s stage to “closed won,” a different set of actions will occur, including submitting the record for finance approval.

Solution: Being the Awesome Admin that she is, Addison is able to solve this declaratively using process builder with the use of a custom permission, a new permission set and adding the custom permission to a profile. Clicks, not code.

UpdateOpportunitiesProcessBuilder.JPG

Note: In this blog post, we assume you have already created the finance approval process for opportunities that are closed won. Addison created an opportunity approval process called “Opportunity Finance Approval.”

Quick Steps:

1. Create a custom permission called the custom permission “OpportunityBypassApproval.” For those using Salesforce Classic, custom permissions can be found in Setup | Develop | Custom Permissions. In Lightning Experience, it is found under Custom Code | Custom Permissions.

Best practice tips:

  • Don’t forget to provide a description so you and other/future admins know what this custom permission is used for.

CustomPermission.JPG

2. Create a permission set called “Bypass Opportunity Approval” and click the “Save button. For those using Salesforce Classic, permission set can be found in Setup | Manage Users | Permission Sets. In Lightning Experience, it is found under Users | Permission Sets.

Best practice tips:

  • Don’t forget to provide a description so you and other/future admins know what this permission set is used for.

BypassOpportunityApprovalPermissionSet.JPG

Under the Apps section, select Custom Permissions.

BypassOpportunityApprovalPermissionSet-CustomPermissions.JPG

Click the Edit button. Select “Opportunity Bypass Approval”, click the Add arrow to add to the Enabled Custom Permissions section and click the “Save” button.

BypassOpportunityApprovalPermissionSet-SelectCustomPermissions.JPG

3. Now, we need to follow the same steps to add the custom permission to the Power Users profile. For those using Salesforce Classic, permission set can be found in Setup | Manage Users | Profiles. In Lightning Experience, it is found under Users | Profiles.

PowerUserProfileJPG.JPG

4. Now, let’s create the process builder for the Opportunity object called “Opportunity Process” and click the “Save” button. For those using Salesforce Classic, permission set can be found in Create | Workflows & Approvals | Process Builder. In Lightning Experience, it is found under Process Automation | Process Builder.

UpdateOpportunitiesProcessBuilder.JPG

OpportunityProcess-ProcessBuilder.JPG

Best practice tips:

  • Don’t forget to provide a description so you and other/future admins know what this process builder is used for.

A. Select “Opportunity” as the object. Select to start the process “when a record is created or edited” and click the “Save” button.

UpdateOpportunitiesProcessBuilder-Opportunity.JPG

B. For the first criteria node, we will call it “Status = Closed Won; Bypass Approval.” Here, we want this process to execute for users who have the custom permission “OpportunityBypassApproval”. We will select to use the formula to evaluate to true since custom permissions can only be access via formula.

Click in the System Variable box.

UpdateOpportunitiesProcessBuilder-1stCriteriaNode-Formula.JPG

Select $Permission.

UpdateOpportunitiesProcessBuilder-1stCriteriaNode-Formula-Perm.JPG

You can either type the API Name of the custom permission or find it in the list. Click on the “Choose” button.

UpdateOpportunitiesProcessBuilder-1stCriteriaNode-Formula-CustomPerm.JPG

Salesforce will insert the syntax for the custom permission “$Permission.OpportunityBypassApproval”

Finish the formula by adding the Opportunity Stage to “Closed Won” and click the “Save” button.

$Permission.OpportunityBypassApproval &&

ispickval([Opportunity].StageName, “Closed Won”)

UpdateOpportunitiesProcessBuilder-1stCriteriaNode-FormulaComplete.JPG

For the process builder illustration purposes, we have one immediate action, which is to update the opportunity closed date to today’s date.

In the Immediate Action box, perform the following actions:

  • Click on “+ Add Action.”
  • Select “Update Records” as the Action Type.
  • Let’s call it “Update Opp Close Date”
  • For Record Type, choose “Select the Opportunity record that started your process”
  • Select “Close Date” with a formula syntax of “today()” in the formula field.

Your screen should look like this. Click the “Save” button.

UpdateOpportunitiesProcessBuilder-2ndCriteriaNode-UpdateOppDate.JPG

C. Now, we need to create the second criteria node. In this case, we want this step to execute for everyone else (those who do not have the OpportunityBypassApproval custom permission and has the opportunity stage to “Closed Won.”

The formula to use here is as follows:

NOT($Permission.OpportunityBypassApproval) &&

ispickval([Opportunity].StageName, “Closed Won”)

UpdateOpportunitiesProcessBuilder-2ndCriteriaNode.JPG

Don’t forget to click the “Save” button.

We will create two immediate actions.

First, similar to the previous criteria, we will update the Close Date to today’s date.

UpdateOpportunitiesProcessBuilder-2ndCriteriaNode-UpdateOppDate.JPG

For the second immediate action, perform the following actions:

  • Select the Action Type “Submit for Approval.”
  • We will call the Action Name “Submit to Finance”
  • And under Approval Process, we will select “Specific approval process” and select the opportunity approval process you created.
  • Check “Yes” for Skip the entry criteria for this process?
  • Click the “Save” button.

Here are the results…

UpdateOpportunitiesProcessBuilder-2ndCriteriaNode-SubmitforApproval.JPG

D. Now, go back to the previous criteria node, click on the “Stop” and select “Evaluate the next criteria” and you will do the same to the second criteria if you have additional criteria to execute on the opportunity record. This is so you can have one process builder for the object, similar to Apex Triggers. Don’t forget to click on the “Save” button.

Note: This new enhancement in Summer 16. If your production org has not upgraded to Summer 16, you will not see this feature.  

UpdateOpportunitiesProcessBuilder-EvaluateCriteria.JPG

E. Now, you are ready to activate your process builder. Click on the “Activate” button.

UpdateOpportunitiesProcessBuilder-Activate.JPG

That’s it! Congrats! You’ve implemented a process using custom permissions.

Now, before you deploy the changes to Production, you need to test your configuration changes.

  1. Login as a user with the custom permission via the Bypass Opportunity Approval permission set
  2. Update an opportunity to stage = “Closed Won” and save.
  3. Verify that the Close Date is updated to today’s date and the record is not submitted into the Finance approval process.
  4. Repeat Steps 2-3 logged in as a user associated to the Power Users profile.
  5. Login as a user who does not have the Bypass Opportunity Approval permission set and repeat Step 3.
  6. Verify that the Close Date is updated to today’s date and the record is submitted into the Finance approval process.  

Deployment Notes/Tips:

  • The new custom permission, permission set and process builder can be deployed to Production in a change set (or can be deployed using a tool such as Dreamfactory’s Snapshot).
  • You will need to manually add the custom permission to the Power Users profile (or can be deployed using a tool such as Dreamfactory’s Snapshot).
  • Activate the process builder as it is deployed as inactive into Production.
  • Add users to the Bypass Opportunity Approval permission set.
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s