Expand my Community achievements bar.

SOLVED

How I create a randon number?

Avatar

Level 4

Hello!

How do I create a number random? I want it just a number that never it repeat (when somebody open the file/form).

I would like that was only 6 numbers. Example: 548758

Is it possible?

1 Accepted Solution

Avatar

Correct answer by
Former Community Member

Here is an example form ....the form will generate an error when you open it because you do not have access to the web service that is being called ....simply ignore that. You are interested in the 1st two examples on the form.

paul

View solution in original post

4 Replies

Avatar

Former Community Member

If you do not want the number to repeat then a random number is not what you want. A random number generator will produce the same number eventually. If you do not want a recurring number I suggest a function that gives you the number of milliseconds from an epoch. This will almost guarantee that you will not get the same number unless two users open the form at exactly the same millisecond.

Paul

Avatar

Level 4

Hi Paul, thanks!

Can you give me a example about this function millisecond?

Avatar

Correct answer by
Former Community Member

Here is an example form ....the form will generate an error when you open it because you do not have access to the web service that is being called ....simply ignore that. You are interested in the 1st two examples on the form.

paul

Avatar

Level 4

Ok! Dude!! It works!!

Thanks! But the number was very large, but I liked!

The following has evaluated to null or missing: ==> liqladmin("SELECT id, value FROM metrics WHERE id = 'net_accepted_solutions' and user.id = '${acceptedAnswer.author.id}'").data.items [in template "analytics-container" at line 83, column 41] ---- Tip: It's the step after the last dot that caused this error, not those before it. ---- Tip: If the failing expression is known to be legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)?? ---- ---- FTL stack trace ("~" means nesting-related): - Failed at: #assign answerAuthorNetSolutions = li... [in template "analytics-container" at line 83, column 5] ----