Expand my Community achievements bar.

Generate a random number and make it STAY after "save"

Avatar

Former Community Member
I searched around this forum and found that I can use this code to generate a random number:

//this.rawValue = Math.round(Math.random() * 1000000);



Works great. only problem is, once I practice on the "real" form and save, close, and reopen - it changes the random number every time. I need to figure out a way to make it save the 1st number it generates when someone opens the form and types info in it....then they save and close, etc.



Can anyone help me? Thanks!!
3 Replies

Avatar

Level 5
save it to a hidden field after generating and then reuse form the hidden field.



Good luck,

SekharN

Avatar

Former Community Member
I don't understand what you mean...can you explain in a little more detail? I'm not a programmar. Thanks!!

Avatar

Level 5
Example steps:

1. Add a hidden field to the same subform with name 'hiddenField'.

2. First time you open 'hiddenField' rawValue will be null.

3. where ever you run the code to generate random number use scenario like this.

if (hiddenField.isNull) {

this.rawValue = Math.round(Math.random() * 1000000);

}else {

this.rawValue = hiddenField.rawValue;

}



Hope this thelps.



SekharN