Forum Discussion

CByler's avatar
CByler
Contributor
8 years ago

How to generate a random numbers prepended with a name?

Can someone help me generate a name which includes random numbers?

 

I need to create a unique Schedule Name for each iteration.  The format needs to be as follows:

 

Sched_123456

 

The 'Sched_' is a constant and I need a random  digits to be created each time it runs.

 

I have a current groovy script that generates a random number (int)(Math.random()*99999) + 10001, however, every time I try to edit it to prepend Sched_, it errors out.

 

I did some searching and found this thread, however, I can't get it to work.  https://community.smartbear.com/t5/SoapUI-NG/ReadyAPI-1-4-1-Inline-Command-is-always-executed/m-p/106263/highlight/true#M24672

 

Appreciate any help!

Cherice

3 Replies

  • Alick's avatar
    Alick
    Occasional Contributor

    I have my random number as a project property i call 'rand' with the value ${=(int)(Math.random()*1000000)} then reference it in the request like this:

    newuser_${#Project#rand}

     

    if that's any help?