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: Count records in SObject Collection Variable Lightning Flow

    • Getting Started with Salesforce Flow – Part 11 (Count Number of records in a Record Collection Variable)

      Posted at 9:10 AM by Rakesh Gupta, on July 17, 2018

      Salesforce Flow allows us to automate business processes by building applications, known as Flows. Using Flows, a user can collect information; or, they can update, edit, or create records in Salesforce. Furthermore, Flows can execute logic, interact with the Salesforce database, call Apex classes, Platform Events, and guide users through various screens to streamline the process of collecting and updating data. 

      Once a Flow is built, an Admin can make the Flow available to the right users or systems.

      If you have a basic understanding of Apex then, you can write a query to get records and count the list size. For example, using Apex, one can get all Contacts that belong to city Alpharetta and, count list size, by writing the following code:

      List<Contact> myContact = new List<Contact>();
      myContact = [Select id, Email from contact where Mailingcity ='Alpharetta'];
      system.debug('Size of List'+myContact.size());

      Now suppose you wonder, can I achieve the aforementioned outcome by using Flow? Well, you are in luck! For, before the recent release, it was very complex to count the records in a Record Collection Variable (Kind of equivalent to Apex list). 

      Count Records in a List

      But, since Spring’18 release, a user can use an Assignment element to count the Record Collection Variable size and store that number in a variable without using the Loop element! 

      Business Use Case

      Edward Backhouse is working as a System administrator at GurukulOnCloud. He received a requirement to count Contact records where Mailing city equals Alpharetta. The new feature of Flow to rescue! 

      The solution for the above business requirement

      There are a few possible solutions for the above business scenario. One of them, of course, is to continue to use the old method, as shown in the preceding screenshot. 

      But, Edward is a Salesforce Ninja-like us! And, therefore, he is always on the lookout for feature enhancements. As a result, Edward knows that, after Summer’18, he can solve the above requirement efficiently! So, instead of resorting to the old method, he takes following the steps:

      1. Edward navigates to Setup (Gear Icon) | Setup | Process Automation | Flows in Lightning Experience.
      2. Then he clicks on the New Flow button – which, in turn, opens the Flow canvas.
      3. Edward creates a Variable (to store record count) as shown in the following screenshot:
        Read the rest of this entry!
      Posted in Salesforce Flow | 6 Comments | Tagged Count Number of records in Flow, Count Number of records in Salesforce, Count Number of records in Visual Workflow, Count records, Count records in Flow, Count records in Lightning Flow, Count records in Salesforce, Count records in SObject Collection Variable, Count records in SObject Collection Variable Flow, Count records in SObject Collection Variable Lightning Flow, Count records in Visual Workflow, Flow builder, Flow Trails, Platform App Builder Exam, salesforce Admin exam, Salesforce Flow, Salesforce Flow Example, Salesforce Freelancer, Salesforce Independent Architect, Salesforce Independent Consultant, Salesforce Online Training, salesforce trainer, Salesforce Training, Trailhead
    • Getting Started with Salesforce Flow – Part 18 (Want to Secure Your Org? Use Login Flow to configure Two Factor Authentication!)

      Posted at 9:26 PM by Rakesh Gupta, on January 29, 2015

      Two-factor authentication is a security process in which the user provides two means of identification, one of which is typically a normal user credential and the other of which is typically something memorized, such as a security code. You can enable Two-factor authentication for users by adding Two-Factor Authentication for User Interface Logins permission through a Profile or a Permission Set.

      Objectives:

      After reading this blog, you’ll be able to: 

      • Understand what is two-factor authentication 
      • How to build custom two-factor authentication using Flow
      • How to use Flow to send an email 
      • Set up Login Flow 

      Business Use Case

      Warren Mason is a System Administrator at Gurukul on Cloud (GoC). He received a requirement to implement Two-factor authentication for Partner Community users who are having profile Partner Community User Clone. 

      What is Two-factor Authentication?

      Two Factor Authentication, or 2FA, is an extra layer of protection used to ensure the security of online accounts beyond just a username and password. This process is done to better protect both the user’s credentials and the resources the user can access.

      Automation Champion Approach (I-do):

      Usually, with Salesforce, multiple approaches are available to solve a business requirement. Choose the ones that are simple, straightforward, and consume fewer resources. 

      Let us solve this scenario using Flow and Login Flow – as this business case involves adding a second factor of authentication after the username and password verification. Before diving further, 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 7 steps to solve Warren’s business requirement using Salesforce Flow. We must:

      1. Create a formula in the Flow to generate Security Code (We are using Current DateTime to do so) 
      2. Store Security Code in a Variable
      3. Send Security Code to User via Email
      4. Allow user to enter Security Code
      5. Validate the Security Code
      6. Add a Screen to display a failure message 
      7. Set up a Login Flow

      Step 1: Create a Formula

      1. Click Setup.
      2. In the Quick Find box, type Flows.
      3. Select Flows then click on the New Flows.
      4. Select the Screen Flow option and click on Create.
      5. Navigate to the Manager tab and click on the New Resource.
      6. Enter API Name and Description. 
      7. Select Number as Data type and enter the Description. 
      8. Use the following formula 
        1. Value(SUBSTITUTE(LEFT(RIGHT(text( {!$Flow.CurrentDateTime} ),9),8), “:”, “” ))
      9. Click Done.

      Step 2: Store Code (Formula value) in a Variable

      1. Create a Number Variable to store the security code generated by Flow formula.
      2. Navigate to the Elements tab and drag-and-drop Assignment element onto the Flow designer. 
      3. Enter Label the API Name will auto-populate.
      4. Set Variable Values:
        1. Row 1:
          1. Variable: {!VarNSecurityCode}
          2. Operator: Equals
          3. Value: {!VarNCode}
      5. Click Done.

      Step 3: Email Security Code

      1. Create a Text Formula to store the logged-In user email address.
      2. Navigate to the Elements tab and drag-and-drop Action element onto the Flow designer. 
      3. Select Send Email core action. 
      4. Enter Label the API Name will auto-populate.
      5. Set Input Values:
        1. Row 1:
          1. Body: Here is your security code {!VarNSecurityCode}
          2. Subject: Security Code – Salesforce
          3. Email Addresses (comma-separated): {!ForTLoggedInUserEmail}
      6. Click Done.

      Step 4: Screen to enter the Security Code

      1. Drag-and-drop Screen element onto the Flow designer. 
      2. Enter Label the API Name will auto-populate.
      3. On the Screen element, navigate to the Input section and double-click on the Number field, to add it on to the Screen element
      4. Enter Label the API Name will auto-populate.
      5. Make sure to select the Require checkbox.
      6. Click Done.

      Step 5: Validate Security Code

      1. Drag-and-drop Decision element onto the Flow designer. 
      2. Enter Label the API Name will auto-populate.
      3. On the First Outcome enter the Label the API Name will auto-populate.
      4. When to Execute Outcome: All Conditions Are Met
        1. Row 1:
          1. Resource: {!VarNSecurityCode}
          2. Operator: Equals 
          3. Value: {!Security_Code}
      5. Click Done.

      Step 6: Screen to display code Mismatched Error

      1. Drag-and-drop Screen element onto the Flow designer. 
      2. Enter Label the API Name will auto-populate.
      3. On the Screen element, navigate to the Display section and double-click on the Display Text field, to add it to the Screen element
      4. Enter API Name. 
      5. You can now use a Rich-text editor to add content like Text, Image, URL, etc.
      6. Click Done.

      In the end, Edward’s Flow will look like the following screenshot:
      Lightning Flow 18 - Final Flow

      Once you’re done, Save the flow and name it Two Factor Authentication. Do not forget to activate the Flow by clicking on the Activate button.

      Step 7: Set up a Login Flow

      1. Click Setup.
      2. In the Quick Find box, type Login Flows.
      3. Select Login Flows then click on the New.
      4. Select the Type from the drop-down Flow.
      5. Enter Two-Factor Authentication as a Name.
      6. The next step is to select Flow, User license, and Profile. Follow the steps as shown in the following screenshot:
      7. Click Done.

      It’s time to test the Login Flow

      Now, if a User with profile Partner Community User Clone successfully logged using a username and password, they will see to our Flow to complete the two-factor authentication process

      Enter your Security Code onto the screen input field and click on the Next button, as shown in the following screenshot: 

       If the Security Code is matched then you will redirect to Salesforce (i.e. Partner Community) else it will display an error message. 

      –> To add a restriction on the number of unsuccessful attempts, you can add one subflow (It will Freeze the user’s account after three or more unsuccessful attempts). Check out the more advanced Login Flow use case here. 

      Great! You are done! Feel free to modify it based on your business requirement. 

      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 Salesforce Flow, User Management, Winter'15 Release | 16 Comments | Tagged Advance flow, Advanced flow, Advanced Lightning Flow Training, Count records in SObject Collection Variable Lightning Flow, Define Login Flow, dev 401, Flow basics, Flow builder, Lightning Flow, Lightning Flow and Login Flow, Lightning Flow and Login use case, Lightning Flow example, Lightning Flow Training, Login Flow, Login Flow Concepts, Login Flow example, LOgin FLow Salesforce example, Partner Community and Flow, Sales cloud, Salesforce Flow, Salesforce Flow Example, Security Code, Security Token, Two Factor Authentication, Two factor authentication for COmmunity, Two factor authentication for Community Salesforce, Two Factor Authentication In Salesforce, Two factor authentication using Login Flow
    • 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 59 (Clone a Chatter Group with Members)
      • New Research: Salesforce Delivery Teams Excel in Speed but at the Expense of Quality
      • Improve Your Data Collection Strategy with Web Forms
      • Getting Started with Salesforce Flow – Part 58 (Customize Previous, Next, Finish, and Pause Button Label for Screen Flow!)
      • Advancing Business Operations with Salesforce and QuickBooks
    • 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
    • Getting Started with Salesforce Flow – Part 43 (Dynamic Approval Routing in Salesforce)
    • Getting Started with Salesforce Flow – Part 57 (Adding Validation to Flow Screen Components)
    • Getting Started with Salesforce Flow – Part 59 (Clone a Chatter Group with Members)
    • 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 1 (Understand, Create & Use Variables in Flow!)
    • Salesforce Spring’21 Release Quick Summary
    • Getting Started with Process Builder - Part 1 (Automatically Create a record)
  • Social Media

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