Add prefix/suffi on a random string

0
Hi,   I want to add a prefix to a rndomly generated string (using “random string” in a microflow)   According to the doc (https://docs.mendix.com/addons/ats-addon/rg-one-random-string/) i just have to add the parameters i want in the java action in studio pro   I can change the length but i can’t add prefix or suffix   Can anyone help me ?   Thanks in advance
asked
4 answers
2

I think you are looking at two different Random String functions. 

You have referenced the documentation for the ATS testing system, but if you are passing a single parameter it sounds like you are actually using RandomString from the Community Commons module.

If you just want a random string with a prefix, I would first call RandomString in CommunityCommons. This returns a String. You can then use the Create Variable action to create a new String where you append this value and your prefix together using something like this...
 

'YourPrefix' + $StringFromRandomStringAction


Hope this helps.

answered
0

Hi,

You can try this way :

 

randomNumber : Integer/Long data type → Set to 0

RandomNumberString : String data type → Set empty string ''

Change randomNumber : round(random()*9999) or round(random()*999) or round(random()*99) or round(random()*9)

Change RandomNumberString : toString($randomNumber)

 

And if incase if you want to set the limit like 4 digit random prefix always then you can go with the following :

randomNumber : Integer/Long data type → Set to 0

RandomNumberString : String data type → Set empty string ''

Change randomNumber : round(random()*9999) 

Add check : length(toString($randomNumber)) >= 4

Change RandomNumberString : toString($randomNumber)

Hope this is helpful!

answered
0

Hi Quentin,

 

After creating random string, use change variable activity in microflow to add prefix to it.

 

Consider this is your generated random string variable name: randomStringVariable 

 

$randomStringVariable  + $prefix 

 

Add the above condition in change variable activity.

answered
0

It’s not working

 

I just wanted a simple solution like in the documentation

 

It’s just a prototype anyway

answered