1142
Views
8
Comments
Solved
Generate a random number
Discussion
Hi everyone!

I'm about as new to outsystems as I possibly can be so please go easy on me! I thought I'd make a little card game simulation for my first module but my 'shuffle' action has me stumped! Usually I'd use a random integer function but I cant find one anywhere. Does anyone know how I can generate a random number in outsystems?

Or if you're feeling extra nice, how would you shuffle the contents of a list in outsystems?

Cheers!
2012-03-16 12-21-09
João Rosado
Staff
Solution
Hi all,

Check this topic: https://www.outsystems.com/forums/discussion/9729/randomizer/
It has an extension to do that.

Regards,
João Rosado
2019-11-12 17-31-26
Justin James
 
MVP
The GeneratePassword() function can do it. There's also a "Random" extension floating around that can meet your needs.

J.Ja
UserImage.jpg
James Bowden
Thanks Justin, where can I find extensions? The generate password isn't appropriate since I need to specify a random number between 0 and <list_length>. 
2019-11-12 17-31-26
Justin James
 
MVP
James -

Go to the "Forge" (link right at the top of the screen) and search in there.

J.Ja
UserImage.jpg
Admilson Tavares
Hi James,
 
You can also do it using an advanced query. In that case, you should do something like this:


UserImage.jpg
James Bowden
That works, thanks guys!
2024-04-05 15-02-07
João Portela
Staff
Hi guys,

Why generate a Random number using the database? I'm certain that you can find one component in the Forge as Justin referred, or if not it could be easily implemented in a extension.

Using the database for simple math operations as this, is not recommended. You are increasing the load of the database server when this operation can be executed easily in the server machine.


regards,
João Portela
2012-03-16 12-21-09
João Rosado
Staff
Solution
Hi all,

Check this topic: https://www.outsystems.com/forums/discussion/9729/randomizer/
It has an extension to do that.

Regards,
João Rosado
UserImage.jpg
Admilson Tavares
I All.
 
I guess you are right João.
 
Despite the sql approach achieve his goal, it is not the best solution
 
Lets keep the database server focused to more appropriate tasks
 
Cheers
Admilson Tavares
Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.