As we all know that Salesforce is forcing the 2-Factor Authentication for all the Salesforce Orgs. Where you must need to verify your identity either using some external devices with the help of some code or using Salesforce Authenticator application.
On-Top of that if you want to add the extra layer of security we can do that with the help of Salesforce Login flows where we can ask users to verify email, phone or other sensitive information.
In this blog post, we will see we can generate the OTP and then use the same in our Login Flow for further blog posts.
Generating the OTP and using it as a second factor of authentication is very important these days. We will see how we can generate the OTP using flow.
Create OTP Object
To store the OTP information for all the users, we will be creating our own custom object. Create the custom object with the following fields.
Login to Salesforce
Navigate to Setup –> Object Manager
Click on Create -> Custom Object
Create the following fields by referring the following screenshot.
Once you have created the custom tab. Now the time is to Create the Apex Class which will generate the OTP and return to the flow record.
Develop the flow
After, we have developed the Apex Class Now the time is to develop the Lightning Flow Builder.
Follow the below steps to create the flows.
Navigate to Setup –> Flows -> Click on “New Flow” button
Select Record Triggered Flow from the type of flows
Add Resource in Flow
Click on the “New Resource”. from the left hand side and create a variable of type “OTP__c”
Add Action in flow
Click on the + Icon and the select Action, From the Search bar Search for Generate OTP and select the custom invocable apex action that you have created as part of custom Apex Class.
Add assignment in flow
Again click on the + Icon and then select the Assignment element.
Prepare the assignment using the below screen. We need to assign the below variables
OTP which we have got from the Apex Action
Status as Generated
Also, we need to map the Record Id so that we can update the OTP Record
Add update record
Now, as we have got the OTP, prepared the assignment. We need to update our OTP record so that we can update the unique code to our OTP record against each user
Click on + Icon and select Update Records element.
Save and test flow
Once you have developed the flow. It will look like below screenshot.
To test the flow, go to the app launcher. Find OTP Tab and then Create a new record.
Note:- Please do not put anything for OTP (Text) field.
Complete video
Thanks for reading! If you have any questions, please post into the comment section.
Amit Singh aka @sfdcpanther/pantherschools, a Salesforce Technical Architect, Consultant with over 8+ years of experience in Salesforce technology. 21x Certified. Blogger, Speaker, and Instructor. DevSecOps Champion
The Salesforce CLI is not just a tool; it’s the cornerstone of development on the Salesforce Platform. It’s your go-to for building, testing, deploying, and more. As one of the most important development tools in our ecosystem
Table of Contents
What is Apex Log Analyzer?
Apex Log Analyzer, a tool designed with Salesforce developers in mind, is here to simplify and accelerate your...
Introduction
Hey Everyone,
Welcome to my podcast, the first-ever podcast in India for Salesforce professionals.
Achievement
We are happy to announce that we have been selected as Top...
can we get verify otp class
There is no such class