Ask a Question

Generate Random Guid (5 digits)

Occasional Contributor

Generate Random Guid (5 digits)


I am looking to generate a simple 5/6 digit random number or string for an ID.  I know I can generate a GUID using ${=java.util.UUID.randomUUID()} in the request but is there a specific way to generate a small number/string?



Community Hero

Hey @Rememo 


you can use the same sort of approach you use to dynamically generate a GUID (e.g. ${=java.util.UUID.randomUUID()}) as to generate a unique number based on the current timestamp or current date, etc., there's also a Math.random() method you can use too.


I'm on the wrong laptop so I'll check later (my ReadyAPI is on a different laptop) - but my question -->  what's the max field length of the unique numbers you want to generate?


Also - I think (going from memory here - I've never actually used it) the DataGenerator (DataSource step option) will also generate unique numbers for you.





if this helped answer the post, could you please mark it as 'solved'? Also if you consider whether the title of your post is relevant? Perhaps if the post is solved, it might make sense to update the Subject header field of the post to something more descriptive? This will help people when searching for problems. Ta
Occasional Contributor

Yeah DataGen script step would actually work as well to create a random 5 digit number.


I used Math.round(10000 + Math.random() * 90000); 

Showing results for 
Search instead for 
Did you mean: