Getting Started with Process Builder – Part 78 (Auto Enable Lightning Experience for New Users)

Getting Started with Process Builder – Part 78 (Auto Enable Lightning Experience for New Users)

Last Updated on December 19, 2020 by Rakesh Gupta

To understand how to solve the same business use case using Salesforce Flow. Check out this article Getting Started with Salesforce Flow – Part 24 (Automatically Assign Permission Sets to New User).

Almost three years back I wrote an article to auto assign Permission Set to new users. I had written the article using, now obsolete, Flow Trigger. You can read it here

Since then, I received several emails, from my readers, requesting me to show how to auto assign Permission Set to new users using Process Builder.

So, here it is! In this article, we will discuss how to assign a Permission Set to new users using Process Builder and Flow. 

Salesforce allows you to add Permission Sets to users, to extend their functionalities without changing their profile. For example, if you want to grant Modify all access on Account objects to a set of users without changing their profile or creating a new profile then, consider using Permission Set. 

Business Use case

Martin Jones is working as a System Administrator at Gurukul on Cloud (GoC) At GoC they have rolled out Lightning Experience for VP of Sales and VP of Marketing only. Martin has received a requirement to enable Lightning Experience for all new users and ensure that all new users undergo training on Lightning Experience. 

Solution for the above business requirement

To solve this requirement we will use Visual Workflow and Process Builder. (#1) Process builder will fire when a new user gets setup and it will trigger the Flow. (#2) Visual Workflow will add permission set to the new user. Before proceeding ahead, you have to understand PermissionSetAssignment (It represents an association between a User and a PermissionSet) objects in Salesforce.

Field Name Details
AssigneeId ID of the user to assign the permission set.
PermissionSetId ID of the PermissionSet to assign to the user.
  1. First of all, we will create a new permission set called Lightning Experience
  2. Then assign the Lightning Experience User system permission to it. 
  3. The next step is to grab the permission set Id, as shown in the following screenshot: The above screenshot shows how to grab Permission Set ID using Developer Console. Now, we need to create a Custom Label to store the aforementioned Permission Set Id.
  4. To create a custom label click on Setup (Gear Icon) | Setup | User Interface | Custom Labels
    1. Click on New Custom Labels; it will open a new window for you. Now, create a new custom label to store the permission set (Lightning Experience) Id, as shown in the following screenshot: 
    2. once you are done, click on the Save button.
  5. The next step is to create a Flow, by clicking on Setup (Gear Icon) | Setup | Process Automation | Flows
  6. Click on New Flow, it will open flow canvas for you.
  7. To access custom label in flow, you must create a formula. Create one formula PermissionSetIDas shown in the below screenshot:
  8. Also create one Text variable to store user id, as shown in the following screenshot: 
  9. To add Permission Set to new users, drag and drop a Record Create ( Give the name Add Permission Set) onto the window and map the fields as shown below:
    1. Select Object PermissionSetAssignment
    2. Enter criteria AssigneeId= {!UserID} and PermissionSetId= {!PermissionSetID}, as shown in the following screenshot: 
  10. Finally, your flow should look like as follows: 
  11. Once you are done, Save the flow with the name (Enable Lightning Experience) with Type: Autolaunched Flow. Don’t forget to activate the Flow by clicking on the Activate button.
  12. The next step is to create a process, that will fire when a new user gets created. To do this, Navigate to Setup (Gear Icon) | Setup | Process Automation | Process Builder
  13. To create a new process from scratch, click on the New Button available on Process Management page. A popup will appear where you have to enter the Name (Use Auto assign permission set  as name)API Name and Description as shown in the screenshot below:
  14. Once you are done, click on the Save button.
  15. Click on the Object node to add object and then select the User object. For the entry criteria, select only when a record is created, as shown in the screenshot below:
  16. Once you are done, click on the Save button.
  17. The next task is to add Process Criteria, so that process will only fire when a user is created and it is active. To do this click on Add Criteria, enter NameType of action and set filter conditions, and follow the instructions below
    1. For Criteria for Executing Actions, select Conditions are met
    2. Set condition –  [User].IsActive Boolean True
  18. Once you are done, click on the Save button.
  19. Now we have to add an Immediate action into the Process to update the Account Name field. Click on Add Action (Under Immediate actions), Select the type of action (In our case Flows), and then fill the values into fields to define the action – as shown in the following screenshot:
  20. Once you are done, click on the Save button. 
  21. In the end, your Process will look like the following screenshot:
  22. Do not forget to activate the Process by clicking on the Activate button.

It’s time to test this feature

Next time, when a User is created by the system administrator, the process we created ( Using Process Builder) will fire and assign Lightning Experience User permission set to the User.

Note: – I am grateful to Resco.net and Smartcloud.io for sponsoring my blog.

Technical Editor and Proofreader: - Munira Majmundar
Have feedback, suggestions for posts, or need more information about Salesforce online training offered by me? Say hello, and leave a message!

15 thoughts on “Getting Started with Process Builder – Part 78 (Auto Enable Lightning Experience for New Users)

  1. Hello All,

    I’m new to salesforce platform.
    when I’m try to create a flow here it has opened a canvas . which flow I need to choose here

    I’m attaching the screen shot here

    Is that a screen flow. please help me

  2. Hi, thanks for your post, however, I would like to ask, this only works when the user is created by system administrator? I’m trying to execute when user is created by a community guest user but is not working.

    1. Nathalia, I am running into the same issue. May I ask how you were able to resolve this? I cannot get it to work for a self-reg Community User.

      1. This is ther error I get: Error element Create_Permission_Assignment (FlowRecordCreate).
        This error occurred when the flow tried to create records: MIXED_DML_OPERATION: DML operation on setup object is not permitted after you have updated a non-setup object (or vice versa): PermissionSetAssignment, original object: Contact. You can look up ExceptionCode values in the SOAP API Developer Guide.
        ________________________________________
        I looked up the error and updated the process builder based on the solution recommendation below but the Self-Reg Community User still cannot be created:

        Scheduled Action is available under the following conditions:

        The Evaluation Criteria setting is:

        ‘Created’
        ‘When a record is created or edited’
        And the ‘Do you want to execute the actions only when specified changed are made to the record?’ is enabled under ‘Advanced’ on the ‘Define Criteria for this Action Group’ page.

        1. I figured out the issue. You cannot perform DML on Salesforce setup objects(User in this case) and non-setup object in the same context. You have to create a time based action and set it to 0. Then the process works as expected.

  3. Hi
    YThanks for the solution! I was able to create the flow and process …however when I try to create new user to test, following error comes up and new user is not created
    “Unable to Access Page
    The value of a parameter contains a character that is not allowed or the value exceeds the maximum allowed length. Remove the character from the parameter value or reduce the value length and resubmit. If the error still persists, report it to our Customer Support team. Provide the URL of the page you were requesting as well as any other related information. “

  4. Thanks so much for this. Do you know how this could be modified to assign more than 1 permission set at user creation? Thanks!

  5. Rakesh Hi,
    As always – Another great post!
    I wish to know how do I automatically add/remove Permission Set from users in Public Groups?
    Example: Once a user is added to a Public Group – He will receive a certain Permission Set. Once he is removed from this group, the Permission Set will be deleted from his user.

    This would be very helpful.

    Thanks,
    Gidi

    1. Great to hear Gidi! Glad it was helpful!

      To answer your question, the one and the only solution is to write a Batch Apex which will run every night to add/remove Permission Set from users in Public Groups

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.