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: Custom button

    • 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 Salesforce Flow – Part 2 (Do You Know How Screen Element Bestows Power on Flow Builder?!)

      Posted at 7:05 AM by Rakesh Gupta, on March 26, 2019

      Check out my previous articles: 

      • Want to be an Early Adopter of the New Flow Builder? Welcome Aboard!
      • Getting Started with Salesforce Flow Designer– Part 1 (Understand, Create & Use Variables in Flow)

      In the aforementioned articles, I have discussed the new Flow Builder tool – introduced by Salesforce in Spring’19 release and some basics concepts of Flow – to help you better understand the elements of a flow builder. If you didn’t get a chance to read it yet, do it now! It will significantly improve your knowledge of Salesforce Flow. Once you master the art of leveraging Salesforce Flow, you will be able to easily create an optimized flow!

      In this article, we will discuss the following topics:

      • What is a Screen Element?
      • What is the purpose of a Screen Element?
      • How to create a Screen Element?
      • Explore different ways to call Flow with Screen Element.

      What is a Screen element? 

      A Screen Element bestows power on Salesforce Flow by making it more robust compared to the Process Builder. You might be thinking how and why? Let’s see through a business use case.

      Business Use Case

      Edward Backhouse is working as System administrator at GurukulOnCloud. Edward received the following requirement from his manager – create a lead capture form which looks like the following screenshot: Read the rest of this entry!

      Posted in Salesforce Flow | 2 Comments | Tagged Custom button, Flow builder, Flow management, Inline Visualforce Page, Learning, Lightning Component, Lightning Flow, Lightning Flow Designer, Lightning Process builder, Process Automation, quick action, salesforce, Salesforce Flow, Salesforce Flow Example, Salesforce Flow use Case, Salesforce Ohana, salesforce release, Screen Element, training
    ← 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

      • Pardot Summer’21 Release: Top 5 Features
      • Salesforce Summer’21 Release Quick Summary
      • Getting Started with Process Builder – Part 60 (Allow Anyone to Add or Remove User into Public Group or Queue)
      • Getting Started with Salesforce Flow – Part 59 (Clone a Chatter Group with Members)
      • New Research: Salesforce Delivery Teams Excel in Speed but at the Expense of Quality
    • 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

    • Salesforce Summer’21 Release Quick Summary
    • Learning Flow
    • Pardot Summer'21 Release: Top 5 Features
    • Learning Process Builder
    • Salesforce Spring’21 Release Quick Summary
    • Getting Started with Salesforce Flow – Part 57 (Adding Validation to Flow Screen Components)
    • Pre-requisites for Learning Apex - Logical Mind and Confidence!
    • Getting Started with Salesforce Flow – Part 11 (Count Number of records in a Record Collection Variable)
    • Getting Started with Salesforce Flow – Part 24 (Automatically Assign Permission Sets to New User)
    • Getting Started with Salesforce Flow – Part 4 (Need to Redirect a User to a New Record?)
  • Social Media

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