Automation Champion

Automating Salesforce One Click at a Time
Automation Champion
  • Home
  • About Me
    • Testimonials
    • Resources
  • Process Builder
  • Salesforce Flow
  • Pardot
  • Apex
  • Training Details
    • Salesforce Administrator
    • Salesforce Advanced Administrator
    • Platform App Builder
    • Lightning Flow
    • Pardot
    • Sales Cloud
    • Service Cloud
    • Community Cloud
    • Hands-on Excercises
  • My Books
  • Contact Me
  • Tag: Salesforce maintenance exam

    • Getting Started with Salesforce Flow – Part 42 (Running a Flow in System Mode)

      Posted at 1:50 PM by Rakesh Gupta, on November 21, 2020

      Big Idea or Enduring Question:

      How do you run a Lightning Flow in system mode? 

      Objectives:

      This blog post will help us to understand the following

      • Difference between user mode vs system mode? 
      • How to create a flow that runs in the system mode

      Business Use case

      Vigne Kozacek is working as a System Administrator at Universal Containers (UC). They normally grant read access to account records to account team members. He received a requirement to develop an application that will allow all users to add Chatter followers to the account record without editing it. (It should also work in case if they have only read access to the account record.)

      Automation Champion Approach (I-do):

      In this article Getting Started with Process Builder – Part 20 (Add Chatter Followers to Record), we had discussed a way to auto-add Chatter followers to an account record using Process Builder. But it will only work for System Administrators or users with the Edit permission on the Account object. There are few business scenarios where a business wants to implement this for all users so that anyone can add followers without editing the account record. Let’s start working through the solution for the business use case.

      We will use Flow and Process Builder because it runs in system mode. Before proceeding ahead, you have to understand User mode and System mode in Salesforce. 

      • System mode: In which the object and field-level permissions of the current user are ignored. 
      • User mode: In which the permissions, field-level security, and sharing rules of the current user are enforced.

      A few points to remember

      • By default, Screen Flow runs in user mode.
        • But Salesforce provides an ability to runs it in system mode.
      • Record-Trigged Flow always runs in system mode.
      • Scheduled-Trigged Flow always runs in system mode.
      • Process Builder runs in system mode.
      • When you launch a Flow using the Process Builder, then it will run in system mode.

      Before discussing the solution, let me show you a diagram of a Process Flow at a high level. Please spend a few minutes to go through the following Flow diagram and understand it.

      Let’s begin building this automation process.

      Guided Practice (We-do):

      There are 5 steps to solve Vigne’s business requirement using Lightning Flow. We must: 

      1. Define flow properties for screen flow
      2. Create a text variable 
      3. Create a screen to capture the user data
        1. Add a screen element
        2. Add a Lookup component 
        3. Add a create records element
      4. Setup the flow runtime mode 
      5. Create a quick action 

      Step 1: Define Flow Properties

      1. Click Setup.
      2. In the Quick Find box, type Flows.
      3. Select Flows then click on the New Flow.
      4. Select the Screen Flow option and click on Next and configure the flow as follows: 
        1. How do you want to start building: Freeform
      5. It will open the flow designer for you.

      Step 2: Create a Text Variable 

      Want the quick action to send the record’s ID to your flow? Create a variable like below and the rest Salesforce will handle for you. 

      1. Under Toolbox, select Manager. Click on the New Resource. 
      2. Input the following information:
        1. Resource Type: Variable
        2. API Name: recordId
        3. Data Type: Text
        4. Default Value: {!$GlobalConstant.EmptyString}
        5. Check Available for Input
        6. Check Available for Output
      3. Click Done. 

      Step 3.1: Add a Screen Element 

      1. Under Toolbox, select Elements. Drag and drop Screen onto the canvas. 
      2. Input the following information:
        1. Enter Label the API Name will auto-populate.
      3. Click Done. 

      Step 3.2: Add a Lookup Component to capture the user data whom they want to make a follower of the record

      1. Under Input section on Screen Element. Drag and drop Lookup onto the screen. 
      2. Input the following information:
        1. Enter API Name.
        2. Field API Name: CreatedById (Enter the field API Name that will show up in the list box to represent a record.)
        3. Label: Select a Follower (Enter a label that appears next to the lookup control)
        4. Object API Name: Account ( Enter the object API name) 
        5. Required: {!$GlobalConstant.True}
      3. Click Done.

      Step 3.3: Add a Create Records Element to add followers into the Record 

      1. Under Toolbox, select Elements. Drag and drop Create Records onto the canvas. 
      2. Input the following information:
        1. Enter Label the API Name will auto-populate.
        2. How Many Records to Create: One
        3. How to Set the Record Fields: Use separate resources, and literal values
        4. Object: Entity Subscription
        5. Set Field Values for the Entity Subscription
        6. Row 1:
          1. Field: ParentId
          2. Value: {!recordId}
        7. Click Add Row
        8. Row 2:
          1. Field: SubscriberId
          2. Value: {!Select_a_Follower.recordId} (RecordId from screen component lookup field added in the step 3.2)
      3. Click Done.

      Step 4: Setup the Flow Runtime Mode

      For a flow running in the user context, the running user’s profile and permission sets determine the object permissions and field-level access of the flow. When a flow attempts to create, read, edit, or delete Salesforce data, it enforces the running user’s permissions and field-level access. For example, if the running user doesn’t have the edit permission for the Account object, and the flow attempts to update account records, an error occurs. If the running user doesn’t have permission to edit the Rating field on the Account object, and the flow attempts to update that field, an error occurs.

      You can set a flow version to always run in the system context, overriding the context it normally runs in. If you choose system context with sharing, the flow respects org-wide default settings, role hierarchies, sharing rules, manual sharing, teams, and territories. But it doesn’t respect object permissions, field-level access, or other permissions of the running user.

      1. Connect the elements. It will look like the image below.
      2. Click Save.
      3. Enter Flow Label the API Name will auto-populate.
      4. Click Show Advanced.
      5. How to Run the Flow: System Context Without Sharing-Access All Data
      6. Type: Screen Flow
      7. API Version for Running the Flow: 50
      8. Interview Label: Add details to Account object {!$Flow.CurrentDateTime}
      9. Click Save. 

      Almost there! Once everything looks good, click the Activate button.

      Step 5: Create a Quick Action – Add Follower 

      The next step is to create a quick action (Add Follower) on the Account object to call the Flow and add it to the page layout. 

      1. Click Setup.
      2. In the Object Manager, type Account.
      3. Select Buttons, Links, and Action, then click New Action.
      4. Input the following information:
        1. Select Flow as Action Type.
        2. Select Add Follower to Record as Flow.
        3. Enter Label the Name will auto-populate.
      5. Click Save.

      Make sure to add the above quick action on the page layout. 

      Proof of Concept

      In this demo, I am going to use Adam Smith’s account (Profile assigned – Standard Read-Only). 

       The next step is to click on the Add Follower button and follow the instructions available on the Flow screen.

      Finally, check out the Follower section available on the record detail page.

      Formative Assessment:

      I want to hear from you!  

      What is one thing you learned from this post? How do you envision applying this new knowledge in the real world? 

      Let me know by Tweeting me at @automationchamp, or find me on LinkedIn.

      Have feedback, suggestions for posts, or need more information about Salesforce online training offered by me? Say hello, and leave a message!

      Posted in Chatter, Process Builder, Salesforce Flow | 5 Comments | Tagged Add Chatter Followers to Record, Add Chatter Followers to Record using PB, Add Chatter Followers to Record using Process Builder, Add Criteria Proces builder, Add follower, Add follower to record, Add subscriber, Add subscriber to record, ADM 201, adm 201 certification, adm 201 salesforce, admin release exam, Advance flow, Chatter, Cloud Flow Designer Workbook, Con 201, Create record through flow, Custom button, dev 401, DEV401, developer release exam, Enable Process Builder, EntitySubscription, Evaluate the rule when a record is created, flow, Flow and PB examples, Flow and Prcoess Builder examples, FLow and Process builder example, Flow Example, Flow examples, Flow in System mode, Flows, Flows run in user mode, follow records, Getting started with Process Builder, How to activate Process builder, how to use Process builder, Launch a Flow, Launch a Flow from Process builder, Lightning App, Lightning Process builder, New Flow, PB, Record Create, Run a Flow in System Context, Run a Flow in System Mode, run in system mode Flow, Run Salesforce Flow in System Context, Run Visual workflow in system mode, Running a Flow in System Context, Running a Flow in System Mode, salesforce, salesforce Admin exam, salesforce certified developer exam, Salesforce Certified Sales Cloud Consultant, salesforce chatter, Salesforce Flow, Salesforce maintenance exam, Salesforce release exam, Salesforce release exam dates, Salesforce release exams, Spring15 process builder, Spring15 Process builder enhancement, Update Records, Visual flow
    • Getting Started with Process Builder – Part 37 (Auto Add Opportunity Team Member to Opportunity Follower)

      Posted at 12:11 AM by Rakesh Gupta, on July 24, 2015

      Big Idea or Enduring Question:

      • How can you automatically add Opportunity Team Members to a follower on an Opportunity?

      Objectives:

      This blog post will help us to understand the following

      • Launch a Flow from Process Builder
      • Use Flow and Process Builder to automatically create an Opportunity Follower when adding an Opportunity Team Member

      Business Use case

      Rachel Gillett is working as a System administrator in Universal Container. She has received a requirement from the management that if a new user is added to the Opportunity team, then auto adds the user as an Opportunity follower.

      Automation Champion Approach (I-do):

      An Opportunity Team is a set of users that usually work together on an opportunity. A typical Opportunity Team might include the account manager, the sales representative, and a pre-sales consultant. In Salesforce a user can follow Chatter groups or Records. As of now, Salesforce does not have any out of the box functionality to auto-follow records when a user is added to a team or etc., apart from the Automatically follow records that you created.

      There are a few possible solutions for the above business scenario. We will use Flow and Process Builder to solve the requirement. Check out this article to understand why we are using after-save record-triggered flow for this scenario. 

      Let’s take a pause here, familiar yourself with the EntitySubscription object in Salesforce. It represents a subscription for a user following a record or another user. A user can subscribe to a record or to another user.

      Field Name Details
      ParentId The ID of the record or user which the user is following
      SubscriberId The ID of the User who is following the record or user

      Before discussing the solution, let me show you a diagram of a Process Flow at a high level. Please spend a few minutes to go through the following Flow diagram and understand it.

      Let’s begin building this automation process.

      Guided Practice (We-do):

      There are 2 steps to solve Rachel’s business requirement using Flow and Process Builder. We must: 

      1. Lightning Flow Steps:
        1. Define flow properties for auto-launched flow
        2. Add a record variable to store opportunity team member record
        3. Add a get records element to find the follower detail
        4. Add a decision element to check if the record variable (from step 1.3) is null or not
        5. Add a create records element to add the opportunity team member to opportunity follower 
      2. Process Builder Steps:
        1. Define process properties
        2. Define evaluation criteria
        3. Define process criteria
        4. Add action – flows 

      Step 1.1: Lightning Flow – Define Flow Properties 

      1. Click Setup.
      2. In the Quick Find box, type Flows.
      3. Select Flows then click on the New Flow.
      4. Select the Autolaunched Flow (No Trigger) option and click on Next and configure the flow as follows: 
        1. How do you want to start building: Freeform
      5. Click Done.

      Step 1.2: Lightning Flow – Add a Record Variable to Store Opportunity Team Member Record

      1. Under Toolbox, select Manager, then click New Resource to store opportunity team member record.
      2. Input the following information: 
        1. Resource Type: Variable
        2. API Name: varROpportunityTeamMember
        3. Data Type: Record
        4. Object Opportunity Team Member
        5. Check Available for Input
        6. Check Available for Output
      3. Click Done.

      Step 1.3: Lightning Flow – Adding a Get Record Element to Find the Opportunity Follower Details 

      The next step is to use the EntitySubscription object to check whether the Opportunity team member is already following the Opportunity or not.

      1. Under Toolbox, select Element. 
      2. Drag-and-drop Get Records element onto the Flow designer. 
      3. Enter a name in the Label field; the API Name will auto-populate.
      4. Select the Opportunity Team member object from the dropdown list.
      5. Select All Conditions Are Met (AND). 
      6. Set Filter Conditions
        1. Row 1:
          1. Field: ParentId
          2. Operator: Equals
          3. Value: {!varROpportunityTeamMember.OpportunityId}
        2. Click Add Condition
        3. Row 1:
          1. Field: SubscriberId
          2. Operator: Equals
          3. Value: {!varROpportunityTeamMember.UserId}
      7. How Many Records to Store:
        1. select Only the firs record
      8. How to Store Record Data:
        1. Choose the option to Automatically store all fields. 
      9. Click Done.

      Step 1.4: Lightning Flow – Using Decision Element to Check the Record Variable (from step 1.3)

      Now we will use the Decision element to check the Record Variable from step 1.3 to find if it returns the record follower status for the current opportunity team member or not. 

      1. Under Toolbox, select Element. 
      2. Drag-and-drop Decision element onto the Flow designer. 
      3. Enter a name in the Label field; the API Name will auto-populate.
      4. Under Outcome Details, enter the Label the API Name will auto-populate.
      5. Condition Requirements to Execute Outcome: All Conditions Are Met (AND)
        1. Row 1:
          1. Resource: {!Check_follower_details}
          2. Operator: Is Null 
          3. Value: {!$GlobalConstant.True}
      6. Click Done.

      Step 1.5: Lightning Flow – Create Records – Add an Opportunity Team member to Opportunity Follower

      To add an Opportunity team member to Record Follower drag and drop a Record Create onto the flow designer and map the fields according to the below details. 

      1. Under Toolbox, select Elements. Drag and drop Create Records onto the canvas. 
      2. Input the following information:
        1. Enter Label the API Name will auto-populate.
        2. How Many Records to Create: One
        3. How to Set the Record Fields: Use separate resources, and literal values
        4. Object: Entity Subscription
        5. Set Field Values for the Entity Subscription
        6. Row 1:
          1. Field: ParentId
          2. Value: {!varROpportunityTeamMember.OpportunityId}
        7. Click Add Field
        8. Row 2:
          1. Field: SubscriberId
          2. Value: {!varROpportunityTeamMember.UserId}
      3. Click Done.

      In the end, Rachel’s Flow will look like the following screenshot: Once everything looks good, perform the steps below: 

      1. Click Save.
      2. Enter Flow Label the API Name will auto-populate.
      3. Click Show Advanced.
      4. API Version for Running the Flow: 50
      5. Interview Label: Add OTP as Opportunity Follower {!$Flow.CurrentDateTime}
      6. Click Save. 

      Almost there! Once everything looks good, click the Activate button.  

      Our next task is to create a Process Builder on the Opportunity Team Member object to launch a Flow. To create a Process Builder on the Opportunity Team Member object follow the below instructions.

      Step 2.1: Define Process Properties

      1. Click Setup.
      2. In the Quick Find box, type Process Builder.
      3. Select Process Builder, then click New.
      4. Name the Process and click the Tab button. The API Name will populate. 
      5. As a best practice, always input a description. 
      6. The process starts when A record changes.
      7. Click Save.

      Step 2.2: Define Evaluation Criteria

      1. Click on the Add Object node to begin selecting the evaluation criteria.
      2. Select the Opportunity Team Member object from the dropdown list.
      3. Start the process only when a record is created.
      4. Click Save.

      Step 2.3: Define Process Criteria

      1. Click the Add Criteria node to begin defining the process criteria.
      2. Name the criteria.
      3. The criteria should execute actions 
        1. Select No criteria-just execute the actions!.. 
      4. Click Save.

      Step 2.4: Add Action – Flows

      1. Below Immediate Actions, click Add Action.
      2. For Action Type, select Flows. 
      3. Name the action.
      4. Select the flow we just created – Add OTP as Opportunity Follower.
      5. Set Flow Variables: 
        1. Row 1:
          1. Flow Variable: varROpportunityTeamMember
          2. Type: Field Reference
          3. Value: Select the Opportunity Team Member record that started your process
      6. Click Save.


      In the end, Rachel’s Process will look like the following screenshot:


      Almost there! Once everything looks good, click the Activate button. 

      Proof of Concept

      1. Navigate to the Opportunity tab, identify the Opportunity, and click on Opportunity Name.Opportunity with no Team Members
      2. Now I’m going to add user Helina Jolly to the Opportunity Team member, as shown in the following screenshot. Once she has been added as an Opportunity Team member, she will be automatically added as a follower of the Opportunity.Final output

      Formative Assessment:

      I want to hear from you! 

      What did you learn from this post, is it relevant to you, and how will you modify the concepts taught in the post for your own business processes? 

      Make a post and tag me on Twitter @automationchamp, using #AutomationChampionPB.

      Have feedback, suggestions for posts, or need more information about Salesforce online training offered by me? Say hello, and leave a message!

      Posted in Chatter, Process Builder, Sales cloud, Salesforce Flow | 4 Comments | Tagged add Chatter follower, Add Chatter Followers to Record using Process Builder, Add follower to record, ADM 201, adm 201 certification, adm 201 salesforce, admin release exam, Advance flow, Apex and Process builder, Auto add Opportunity Team, Auto add Opportunity Team Member to Opportunity follower, Chatter and Process builder example, developer release exam, Enable Process Builder, EntitySubscription, flow, flow builder in salesforce, flow builders, Flow examples, Flow exmple, Getting started with Process Builder, How to activate Process builder, Lightning Flow, lightning flows in salesforce, New Opportunity Team to Folloer, Process builder and Apex method, sales force automation software, salesforce, salesforce automation, salesforce automation tools, salesforce certified developer exam, salesforce flows, salesforce lightning flow, salesforce lightning flow examples, Salesforce maintenance exam, Team member to record follower
    ← Older posts
    • Search

    • Upcoming Trainings

      Salesforce Administrator Certification
      Salesforce Advanced Administrator Certification
      Salesforce Platform App Builder Certification
      Lightning Flow & Process Builder
      Advanced Lightning Flow
      Pardot Specialist & Consultant Certification
      Sales Cloud Consultant Certification
      Service Cloud Consultant Certification
      Community Cloud Consultant Certification
    • Sponsor #1

    • Sponsor #2

    • Sponsor #3

    • Sponsor #4

    • Order Now!

    • Buy My Book

    • Buy My Book

    • Recent Posts

      • Getting Started with Salesforce Flow – Part 58 (Customize Previous, Next, Finish, and Pause Button Label for Screen Flow!)
      • Streamline Data Collection with Salesforce-Connected Forms
      • Getting Started with Salesforce Flow – Part 56 (Merge Chatter Topics with the Help of Salesforce Flow)
      • Getting Started with Salesforce Flow – Part 57 (Adding Validation to Flow Screen Components)
      • Getting Started with Salesforce Flow – Part 55 (Add or Remove Followers to a Record with the Help of Salesforce Flow)
    • Salesforce ID Converter Build on Lightning Flow

      Converting 15 digit ID to 18 digit Salesforce ID
    • Blog Archives

    • Categories

  • Information

    • About Me
    • Affiliate Disclaimer
    • Contact Me
    • Privacy Policy
  • Top Posts

    • Learning Flow
    • Learning Process Builder
    • Salesforce Spring’21 Release Quick Summary
    • Getting Started with Process Builder - Part 1 (Automatically Create a record)
    • Getting Started with Salesforce Flow – Part 11 (Count Number of records in a Record Collection Variable)
    • Getting Started with Salesforce Flow – Part 4 (Need to Redirect a User to a New Record?)
    • Getting Started with Process Builder – Part 2 (Adding a Time-dependent Action)
    • Add mass members into Queues through Data Loader
    • Getting Started with Process Builder – Part 3 (Automatically Clone a Record if it Meets Certain Criteria)
    • Getting Started with Salesforce Flow – Part 24 (Automatically Assign Permission Sets to New User)
  • Social Media

    • View Automationchampion’s profile on Facebook
    • View Automationchamp’s profile on Twitter
    • View Rakeshistom’s profile on GitHub