OTP is a "One-Time Password" which is randomly generated and sent to your registered mobile number or email address for validation of your transaction. In MS Dynamics NAV, OTP authentication can add an extra layer of security to our Environments. This is basically also known as two-factor authentications.
In this scenerio, we will see
how we can use OTP functionality in NAV and i am using Nexmo here
to implement it.
Step-1 Firstly, Create a new
account on Nexmo or you may use any other SMS service provider to get the API
and their Secret Key.Here i have created a free account for Testing Purpose using this Url -https://nexmo.com/
Once you have created an account, you will get
your API credentials in the dashboard. Use the "API Settings" link to
the right near the top of the screen to reveal the API key & its secret.
Step-2 Now, we need to create a new page and declare a global variable named "InputOTP" then set that variable as a field. And also need to create a global function (with Return Type - Integer) in page to flow the entered OTP to our Codeunit.
Step-3 Then, Create a new Codeunit in object Range and define the below described functions with some local & global variables as shown below:
NOTE: (1) Change the message content as assign in RandomParam Variable.
(2) Change the API Key &
their Secret as you shown in Nexmo Dashboard after you login
with your account, created in step-1.
(3) Also define the Mobile
No. with country code like (919876543210) on which you want OTP SMS.
Once everything is done, When a user tries to Run this
codeunit s/he will get an OTP on their phone. They will see a dialog in NAV and
must enter the OTP. They get three tries to do so.
Output :- The output screen look like this:-
Here, I have created Action buuton on Company
Information Page to Rub this CodeUnit.
While clicking on OK button after entering OTP, nothing happens as we have not
write anything in code.
Note :- Beside of using this function "OnBeforeSomething" we
can also set Event subscriber here to use this functionality on after exact
action where we want.
I hope this article is
helpful for all Business Central Lovers.
Stay
in touch for more content.😉
Comments
Post a Comment