String question - variables

Hi all,

Please see the flow below. I have 10 URL’s that I want to open based on a value in a datatable.
In the below example I simplified it and the value would be “GAR”. I would then like to open the URL defined in the variable pathGAR. But as it is now, it will only open the browser and type “pathgar” in the address bar.

I know the answer will be simple but I can’t find what to type in the “open browser” activity.

Use a switch to define the path depending on sector - you would then enter the same variable string

i.e. Open browser activity input would be path
Switch Sector (String)
Case GAR : path = addressX
Case CWR : path = addressY

2 Likes

you can’t build the variables by concatenating strings.

Directly use pathGAR in the Open Browser Activity.

2 Likes

@TimK, @KarthikByggari,

That is how I am doing it right now. But I have to multiply the same code in the switch 10 times then. The code is very extensive and my Uipath is workflow is getting very slow…

at the moment your statement will put the URL as pathGAR

You need to assign a variable before and use that variable as the open browser URL

Break down your code into smaller components and use invoke workflow file - this helps with efficiency of running your robot

1 Like

I know, that is where I am struggling a bit at.
Imagine I get “GAR” as a variable value, how should I use the assign then to concatenate it with the (predefined) word “path”? I tried “path”+sector.tostring or “path”+‘sector.tostring’, but none is giving me the result.

I’m sorry but I did not get the 'invoke workflow part" :).

Hi.

You are essentially wanting to say “If “GAR” then use pathGAR” right? I think you will want to use a Switch, then create a different variable to represent the path. This is what @TimK is recommending.

The other option would be to have all the paths in an array, then just loop through them if the intent was to process each path. But let us know if you want to take that approach instead.

The switch approach would look like this I think:

So in the switch, it would see the sector, then assign the url to the same variable in each Case. Therefore, when it gets to the Open Browser it can use that variable as the url.

Regards.

1 Like

Ok got it, I was now using a switch and duplicating all my code in each switch case… This will be much better!
Thanks all!

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.