DAXSPOT

Monday, May 20, 2019

Generate Random Integer

Hi,
Today i faced an scenario, where i need to generate a OTP for specific number of digits. With help of some blog references i got to achieve it.
Below code helped me to achieve the requirement.

RandomGenerate randomGenerate;
randomGenerate = RandomGenerate::construct();
randomGenerate.parmSeed(new Random().nextInt());
switch(numberOfDigits)
{
case 5:
RandomNo = randomGenerate.randomInt(10001,99999); //5 digits
break;
case 9:
RandomNo = randomGenerate.randomInt(100000001,999999999); //9 digits
break;
}

No comments:

Post a Comment

How to execute SQL directly form Dynamics AX X++

How to execute Sql directly form Dynamics AX X++ Reference by : alirazazaidi Dynamics Ax provide many other ways to communicate with databas...