Final Up to date on October 10, 2022 by Rakesh Gupta
Massive Concept or Enduring Query:
- Learn how to restrict the variety of concurrent periods for a person?
Goals:
After studying this weblog, you’ll have the ability to:
- Perceive concurrent periods and establish them utilizing Stream
- Restrict the Variety of Concurrent Classes with Login Flows
- Use LoginFlow_ForceLogout variable
- Work with Get Information, Delete Information, Project, and Display Components
- And way more
Rachel Gillett is working as a Junior Developer at Gurukul on Cloud (GoC). She has acquired the next requirement from the administration:
- Implement the variety of concurrent periods per person to at least one.
- Present a capability to kill their earlier session and begin a brand new session when login-In.
Automation Champion Strategy (I-do):
Person Concurrent periods confer with the variety of interactive, UI-based periods a person person can have open and lively per person account. Customers could create a number of person periods as they log in to an account from completely different browser varieties and units.
To boost the safety of the general Salesforce org, an administrator can implement a Login Stream or use the Transaction Safety Coverage (Requires Salesforce Defend or Salesforce Occasion Monitoring add-on subscriptions) to restrict the variety of concurrent periods for a person.
There are a number of doable options for the above enterprise situation. We’ll use Display Stream and Login Stream to resolve the requirement.
Earlier than we proceed additional, allow us to perceive the traits of an AuthSession object – It represents a person person session in your group.
Area Identify | Particulars |
UserId | Person |
ParentId | The 18-character ID for the guardian session, if one exists (for instance, if the present session is for a canvas app). If the present session doesn’t have a guardian, this worth is the present session’s ID. |
SessionType | The kind of session. Frequent ones are UI, Content material, API, and Visualforce. |
UserType | The type of person for this session. Varieties embrace Normal, Companion, Buyer Portal Supervisor, Excessive Quantity Portal, and CSN Solely. |
Earlier than discussing the answer, let me present you a diagram of a Course of Stream at a excessive stage. Please spend a couple of minutes going via the next Stream diagram and understanding it.
Let’s start constructing this automation course of.
Guided Follow (We-do):
There are 7 steps to resolve Rachel’s enterprise requirement utilizing Display Stream and Login Stream. We should:
- Outline movement properties for display screen movement
- Add a Get Information factor to seek out the logged-in person’s periods
- Add an Project factor to get the rely of logged-in person’s periods
- Add a Determination factor to verify whether or not the rely is bigger than 1 or not
- Add a Display factor to show the message and the choice to kill different periods
- Add a Determination factor to verify if the person needs to kill different periods
- If the choice is chosen:
- Add a Get Information factor to seek out the logged-in person’s present session
- Add a Delete Information factor to kill different periods
- If the choice NOT is chosen:
- Add an Project factor to drive logout person
- If the choice is chosen:
- Configure Login Stream for Salesforce Platform licensed customers
👉 Think about using customized metadata varieties to make the variety of present periods configurable.
Step 1: Outline Stream Properties
- Click on Setup.
- Within the Fast Discover field, sort Flows.
- Choose Flows, then click on on the New Stream.
- Choose the Display Stream choice and click on on Create and configure the movement.
- It’ll open the movement designer for you.
Step 2: Including a Get Document Component to Discover the Logged-In Person’s Classes
The subsequent step is utilizing the AuthSession object to seek out the logged-in person’s periods.
- On Stream Designer, click on on the +icon and choose the Get Information factor.
- Enter a reputation within the Label subject; the API Identify will auto-populate.
- Choose the Auth Session object from the dropdown checklist.
- Choose All Situations Are Met (AND).
- Set Filter Situations
- Row 1:
- Area: UserId
- Operator: Equals
- Worth: {!$Person.Id}
- Click on Add Situation
- Row 2:
- Area: ParentId
- Operator: Is Null
- Worth: {!$GlobalConstant.True}
- Click on Add Situation
- Row 3:
- Area: SessionType
- Operator: Does Not Equal
- Worth: TempUIFrontdoor
- Click on Add Situation
- Row 4:
- Area: SessionType
- Operator: Does Not Equal
- Worth: InternalServiceCall
- Row 1:
- How Many Information to Retailer:
- Choose All document
- Learn how to Retailer Document Knowledge:
- Select the choice to Mechanically retailer all fields.
- Click on Accomplished.
Step 3: Including an Project Component to Discover the Depend of Logged-In Person’s Session
The subsequent step is to get the logged-in person’s session rely. For this, we’ll use an Project factor.
- Create a Quantity Variable varN_SessionCount to retailer the rely.
- On Stream Designer, click on on the +icon and choose the Project factor.
- Enter a reputation within the Label subject; the API Identify will auto-populate.
- Set Variable Values
- Row 1:
- Area: {!varN_SessionCount}
- Operator: Equals
- Worth: {!Get_Sessions}
- Row 1:
- Click on Accomplished.
Step 4: Add Determination Component to Verify Whether the Session Depend is Larger than 1 or Not
Now we’ll use the Determination factor to verify the quantity variable from step 3 to seek out if the rely is bigger than 1 or not.
- On Stream Designer, click on on the +icon and choose the Determination factor.
- Enter a reputation within the Label subject; the API Identify will auto-populate.
- Underneath End result Particulars, enter the Label the API Identify will auto-populate.
- Situation Necessities to Execute End result: All Situations Are Met (AND)
- Row 1:
- Useful resource: {!varN_SessionCount}
- Operator: Larger Than
- Worth: 1
- Row 1:
- Click on Accomplished.
Step 5: Add a Display Component to Show the Message and Choice to Kill Different Classes
- Underneath Block Node, click on on the +icon and choose the Display factor on Stream Designer.
- Enter the next data:
- Enter Label the API Identify will auto-populate.
- Take a look at the video for step-by-step directions and a few suggestions.
Step 6: Add Determination Component to Verify If the Person Desires to Kill the Different Classes or Not
Now we’ll use the Determination factor to verify if the person has chosen Signal out all different internet periods checkbox in step 5 or not.
- On Stream Designer, click on on the +icon and choose the Determination factor.
- Enter a reputation within the Label subject; the API Identify will auto-populate.
- Underneath End result Particulars, enter the Label the API Identify will auto-populate.
- Situation Necessities to Execute End result: All Situations Are Met (AND)
- Row 1:
- Useful resource: {!Sign_out_all_other_web_sessions}
- Operator: Equals
- Worth: {!$GlobalConstant.True}
- Row 1:
- Click on Accomplished.
Step 6.1.1: Including a Get Document Component to Discover the Logged-In Person’s Present Session
The subsequent step is utilizing the AuthSession object to seek out the logged-in person’s present session.
- Underneath Sure Node, click on on the +icon and choose the Get Information factor on Stream Designer.
- Enter a reputation within the Label subject; the API Identify will auto-populate.
- Choose the Auth Session object from the dropdown checklist.
- Choose All Situations Are Met (AND).
- Set Filter Situations
- Row 1:
- Area: UserId
- Operator: Equals
- Worth: {!$Person.Id}
- Click on Add Situation
- Row 2:
- Area: ParentId
- Operator: Is Null
- Worth: {!$GlobalConstant.True}
- Click on Add Situation
- Row 3:
- Area: SessionType
- Operator: Equals
- Worth: UI
- Row 1:
- Kind Auth Session Information
- Kind Order: Descending
- Kind By: CreatedDate
- How Many Information to Retailer:
- Choose Solely the primary document
- Learn how to Retailer Document Knowledge:
- Select the choice to Mechanically retailer all fields.
- Click on Accomplished.
Step 6.1.2: Add a Delete Information Component to Kill Different Classes
- On Stream Designer, click on the +icon and choose the Delete Information factor.
- Enter a reputation within the Label subject; the API Identify will auto-populate.
- For Learn how to Discover Information to Delete, choose Specify situations.
- Choose the Auth Session object from the dropdown checklist.
- Set Filter Situations
- Row 1:
- Area: UserId
- Operator: Equals
- Worth: {!$Person.Id}
- Click on Add Situation
- Row 2:
- Area: ParentId
- Operator: Does Not Equal
- Worth: {!Get_Most_Recent_Session.Id}
- Click on Add Situation
- Row 3:
- Area: Id
- Operator: Does Not Equal
- Worth: {!Get_Most_Recent_Session.Id}
- Row 1:
- Click on Accomplished.
Step 6.2.1: Including an Project Component to Pressure Logout Person
The subsequent step is to kill the person’s present session forcefully. For this, we’ll use an Project factor.
- Create a Boolean Variable LoginFlow_ForceLogout. When this variable is about to
true
The person is instantly logged out. - Underneath No Node, click on on the +icon and choose the Project factor on Stream Designer.
- Enter a reputation within the Label subject; the API Identify will auto-populate.
- Set Variable Values
- Row 1:
- Area: {!LoginFlow_ForceLogout}
- Operator: Equals
- Worth: {!$GlobalConstant.True}
- Row 1:
- Click on Accomplished.
- Add a Display factor with no contents.
In the long run, Rachel’s Stream will appear like the next screenshot:
As soon as every little thing seems good, carry out the steps beneath:
- Click on Save.
- Enter Stream Label; the API Identify will auto-populate.
- Click on Present Superior.
- API Model for Working the Stream: 56
- Interview Label: Concurrent Classes Exceeded {!$Stream.CurrentDateTime}
- Click on Save.
Nearly there! As soon as every little thing seems good, click on the Activate button.
Step 8: Configure Login Stream for Salesforce Platform Licensed Customers
- Click on Setup.
- Within the Fast Discover field, sort Login Flows.
- Choose Login Flows, then click on on the New.
- Choose the Kind from the drop-down Stream.
- Enter Concurrent Classes a Identify.
- The subsequent step is to pick out Stream, Person license, and Profile. Observe the steps as proven within the following screenshot:
- Click on Accomplished.
Proof of Idea
Take a look at the video for a demo:
Formative Evaluation:
I need to hear from you!
What’s one factor you realized from this submit? How do you envision making use of this new data in the true world? Be happy to share within the feedback beneath.
Source link