Alfasith AX

Alfasith AX
اللَّهُمَّ انْفَعْنِي بِمَا عَلَّمْتَنِي، وَعَلِّمْنِي مَا يَنْفَعُنِي، وَزِدْنِي عِلْمًا

Thursday, February 18, 2021

RandomNumbers In AX /D365

 Hi,


static void CreateRandomNumbersInAX(Args _args)

{

    RandomGenerate randomGenerate;

    ;

    randomGenerate = RandomGenerate::construct();

    randomGenerate.parmSeed(new Random().nextInt());

    info(int2str(RandomGenerate.randomInt(0,2147483647)));   //RandomInt(RangeFrom,RangeTo)

    //Note: Range from should be more than natural number 0 and more.

 

}

OutPut

1786303728


To understand the formula behind this random number please refer randomInt() in RandomGenerate class.

The formula in randomNumber generation is not similar to library function of dotnet.

Note: We cannot treat this randomGenerated Values as primary key, this may repeat with same range.

Regards,



No comments:

Post a Comment

How find size of recordsortedlist in D365/AX 2012

Hi, This is the continuity of the previous article where we are now getting the size of recordsortedlist . if(recordsortedlist.len() >1) ...