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.
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.
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.
Create the following fields by referring the following screenshot.
For formula fields here is what we have
Once You have created the OTP object also create the custom tab for the same. Follow the steps from the below link
https://help.salesforce.com/s/articleView?id=sf.creating_custom_object_tabs.htm&type=5
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.
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.
Click on the “New Resource”. from the left hand side and create a variable of type “OTP__c”
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.
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
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.
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.
Thanks for reading! If you have any questions, please post into the comment section.
can we get verify otp class
There is no such class