How can I generate random string

I need to generate a random string of length 10. Is there any provision for that in UI Path.
Example: I have 3 text box which I need to enter the text. I can use a random generator to generate a string of size 10 which will go in text box 1 and another string generated which goes in textbox 2 and like wise for 3 as well.

How can I achieve this.

Thanks
Arun

2 Likes

Hi @Arunchettur,

You can try this

const string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
return new string(Enumerable.Repeat(chars, length)
  .Select(s => s[random.Next(s.Length)]).ToArray());

Let me know if it works

Thanks,
Prankur

Where should I code this in UI Path?

Have a string variable for constant string value ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789

Then create an array variable and assign this to it new string(Enumerable.Repeat(chars, length) .Select(s => s[random.Next(s.Length)]).ToArray());

Thanks,
Prankur

1 Like

GenerateRandomAlphanumeric.zip (1.9 KB)

Check this out and let me know if this helps.

Note: the workflow currently generates 5 random strings. You can change the while condition and generate AS MANY strings as possible.

4 Likes

See if this helps,

RandomStringGenerator.xaml (5.6 KB)

Thanks,
Rammohan B.

4 Likes

I am getting some compilation error. Could you share xaml file please

It works thanks but why do we need to use System.IO.Path.GetRandomFileName and then tweak it for a string name. Does UIPath has other libraries other than filename

See this

Main.xaml (7.8 KB)

Thanks,
Prankur

4 Likes

Awsome bro thnx. How did you learn all there stuffs

1 Like

Still learning :grinning:

1 Like

I use java + selenium for web automation. I find bit difficult to handle UIPath for webautomation.
:smile:

1 Like

UiPath is more easier than Java + Selenium… hope you need to understand UiPath web development activities… then you will enjoy!
.

2 Likes

Thanks its worked. I added message box and directly wrote the text line to get the output. Earlier when i tried to run I was getting no message. what is guid library for?

GUID (global unique identifier)

A GUID (global unique identifier) is a term used by Microsoft for a number that its programming generates to create a unique identity for an entity such as a Word document. GUIDs are widely used in Microsoft products to identify interfaces, replica sets, records, and other objects.

Thanks,
Prankur

4 Likes