Random and a unique number for a string attribute

0
 hi I try to create for the product  a random  and a unique number  but I couldn't find a way? could you please help me?  
asked
1 answers
1

Hi Huseyin,

You can either choose to have an auto increment (which is the easest way), that you can set as datatype in your entity attribute properties. Or you mannually add an attribute that you fill with the Random function, which you can do with a Microflow Action, and check the previous created objects on that value.

So in case of Random:
1. Retrieve all the entities that have that random value
2. Create a variable gotValidRandom and set it to false; 
3. after variable set a while loop, that keeps running until gotValidRadom is true.
4. Within the loop create a random value with the random function 
5. Run the List operation Find on the retrieved list (step 1).
6. if it finds the random value, run the loop again. If not, set the gotValidRandom to true
7. when loop is doen, use the new Random value.

Hope this will get you going.

Good Luck,
Jan 

answered