Getting Started with Process Builder – Part 58 (Restrict users on switching from Lightning Experience to Classic)

Getting Started with Process Builder – Part 58 (Restrict users on switching from Lightning Experience to Classic)

Last Updated on April 15, 2019 by Rakesh Gupta

Lightning Experience is a new, fast, modern user interface experience from Salesforce. Lightning Experience comprises numerous of new features and completely redesigned pages, but remember that not every Salesforce feature is supported in Lightning Experience as of Winter’17 release. For example, a dashboard created in Lightning Experience can not be editable in Salesforce Classic. Salesforce allows their customers to switch back and forth from Lightning to Classic or vice-versa using Switcher, as shown in the following screenshot

Switch to Salesforce Classic
Switch to Salesforce Classic

Learn more about how to enable Lightning Experience for your organization, by navigating to Lightning Experience Trailhead module. Let’s start with a business use case 

Business Use case

Cathal Murtagh is working as System administrator at Universal Containers. They have just enabled Lightning Experience for Sales Reps EMEA profile. To make sure that Sales Reps EMEA users adopt the new experience, they want to disable the Switch to Salesforce Classic functionality, so that they are forced to use new Lightning Experience. Here is the idea link Disable access to classic UI

Solution for the above business requirement

There are a few possible solutions for the above business scenario, but I’ll use Process Builder and Flow to solve the above business requirementBefore proceeding ahead, you have to understand User objects and its fields in Salesforce

A) UserPreferencesLightningExperiencePreferred :- When this field is true, redirects the user to the Lightning Experience interface. In other words, what happen when users click on Label Switch to Lightning Experience or Switch to Salesforce Classic. 

Flow Chart

Follow the below instructions to create a Process for the above business requirement

Assumption: – Lightning Experience is already enabled for Sales Reps EMEA profile. 

1. Click on Name | Setup | App Setup | Create | Workflows & Approvals | Flows
2. Click on New Flow button and it will open the Flow canvas for you. Now create two variables to store the user’s Id and UserPreferencesLightningExperiencePreferred preference, as shown in the following screenshots

VarTUserID
VarTUserID
VarTUserPreferencesLightningExperiencePreferred
VarTUserPreferencesLightningExperiencePreferred

–> A variable is used to store the value. You can use the variable throughout your Flow. For example, while creating the record, performing an update or with delete operations.

3. The next step is to find the loggedIn user current preferences for User Interface. To do that drag-and-drop Record Lookup element (Enter the name LoggedIn User’s user interface preference) onto the canvas and map the fields according to below details

  • Select Object User
  • Id = {!VarTUserID}
  • UserPreferencesLightningExperiencePreferred = {!VarTUserPreferencesLightningExperiencePreferred}, it will look like the following screenshot 
Find User's current preferences
Find User’s current preferences

–> Record Lookup element allow you to extract one record that meets the filter criteria. 

4. The next step is to check the variable {!VarTUserPreferencesLightningExperiencePreferred} to identify the loggedIn user preferences for user interface. For this, we will use Decision element. Drag-and-drop Decision element (Enter the name Check UserPreferencesLightningExperiencePreferred Current Status) onto the canvas, as shown in the following screenshot

User Preferences for LightningExperience
User Preferences for LightningExperience

5. The final step is to update the user interface to Lightning Experience. For this, we will use Record Update element. Drag-and-drop Record Update element (Enter the name Update the User Interface to Lightning Experience) onto the canvas and map the fields according to below details

  • Select Object User
  • Id = {!VarTUserID}
  • UserPreferencesLightningExperiencePreferred = {!$GlobalConstant.True}, it will look like the following screenshot
Update the User Interface to Lightning Experience
Update the User Interface to Lightning Experience

–> Record Create element allow you to create a record in Salesforce using the values from the Flow. 

Finally, your Flow will look like the following screenshot

flow-to-set-lex

6Save the Flow (Type : – Autolaunched Flow) with name Restrict users on switching from Lightning Experience to Classic and close the canvas. Don’t forget to Activate the Flow.

Activate a Flow
Activate a Flow

–> If the Flow doesn’t have a start point then you will not get an activate link on the Flow detail page. 

Launch a Flow from Process Builder

Our next task is to create a Process Builder on the User object to start a Flow. To create a Process Builder on the User object follow the below instructions

1.  Click on Name | Setup | App Setup | Create | Workflows & Approvals | Process Builder
2.
 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 Restrict users on switching from Lightning Experience to Classic PB as name)API Name and Description as shown in the below screenshot

Define Process Properties
Define Process Properties

3. Click on Object node to add object and then select User object. For the entry criteria, Select when a record is created or edited, as shown in the below screenshot. Once done, click on the Save button

Evaluation Criteria
Evaluation Criteria

4. The next task is to add Process Criteria. To do this click on Add Criteria, enter NameType of action and set filter conditions as shown in the following screenshot.

  •  [User].Profile.Name Equals String Sales Reps EMEA
Process Criteria
Process Criteria

5. The next step is to add an Immediate action to Process. Click on Add Action (Under Immediate actions), Select the type of action to create (In our case Flows). Use Field Picker to choose the field [User].Id, as shown in the following screenshot.

Add action – Flows
Add action – Flows

6. Once done, click on the Save button, it will redirect you to Process canvas. Finally, the Process will look like the following screenshot

restrict-users-on-switching-from-lightning-experience-to-classic-pb

Don’t forget to active the Process by clicking on the Activate button.

It’s time to test the Flow and Process

Update: – If you encounter an error message like this while updating a user record “The flow failed to access the value for myVariable_current.Profile.Name because it hasn’t been set or assigned.”, Please move profile check from Process builder to Flow. 

If you have feedback, suggestions for posts or need more information about Salesforce online training program running by me. Say hello and leave and message to me!

 

One thought on “Getting Started with Process Builder – Part 58 (Restrict users on switching from Lightning Experience to Classic)

Leave a Reply

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