SBX - Search With Button

SBX - Forum Post Title

Random Function

Microsoft Dynamics NAV Forum

jsshivalik asked a question on 8 Feb 2019 3:59 AM
My Badges

Question Status

Suggested Answer

Hi

  How the below code works

RandomDigit := CREATEGUID;
RandomDigit := DELCHR(RandomDigit,'=','{}-01');
RandomDigit := COPYSTR(RandomDigit,1,10);

Thanks

Reply
Teddy Herryanto responded on 10 Feb 2019 2:21 PM
My Badges
Suggested Answer

In order to generate a random digit, you can use RANDOMIZE in NAV.

However, the RANDOMIZE function in NAV is not a true random number, because it is based on an algorithm.

The CREATEGUID is generating a GUID ("Globally Unique Identifier") which is more random / unique than using RANDOMIZE.

So the code basically generate a long random code.

Remove unnecessary characters from the code.

Cut the code into 10 characters.

Reply
Teddy Herryanto responded on 10 Feb 2019 2:21 PM
My Badges
Suggested Answer

In order to generate a random digit, you can use RANDOMIZE in NAV.

However, the RANDOMIZE function in NAV is not a true random number, because it is based on an algorithm.

The CREATEGUID is generating a GUID ("Globally Unique Identifier") which is more random / unique than using RANDOMIZE.

So the code basically generate a long random code.

Remove unnecessary characters from the code.

Cut the code into 10 characters.

Reply

SBX - Two Col Forum

SBX - Migrated JS