How to generate random number in Siebel eScript?

Recently I had a requirement to generate non-repetitive random numbers in siebel escript. I searched the siebel tools help and found Clib.rand() function to the rescue. And using it was also very simple.

var temp = Clib.rand();

But this function do not guarantee the non-repetitive output. Instead of building any complex algorithm, to get non-repetitive random number i used Date object and getTime method. As time is allways incrementing and it never looks back :) i used this as my random number.

This method returns the date-time, in milliseconds, of the Date object.

var aDate = new Date().getTime();

Try it out it never fails.
One point to note here is that if requirement is to get series of random number in loop, then you have to add some delay of about a millisec so that system time is updated. njoy!!

Other Siebel Blogs

siebel-admin-l @ IT - toolbox

siebel-dev-l @ IT - toolbox