Putting variable in Asset on Orchestrator

Hello everyone,
from yesterday I’m facing some issue while trying to put the string asset on Orchestrator with variable included. It’s path to some file, and for example it looks like this:
"C:\Users"+Environment.UserName+“Desktop\file.txt”
After UiPath downloads this asset, it doesn’t convert automatically Environment.UserName to the current user name. It just pasting the whole expression.

Is it possible to include variables in assets? Of course it could be resolved by giving instead of Envrionment.UserName some “#” for example, and then split this in the studio by this extra character, and put variable directly then. But it’s kind of not aesthetic for me.

Does anyone of you faced common issue? Could you share your experience?
Thank you.
Kind regards

@olgu - I guess it is expected behavior :frowning: Since it is quoted [return value is string] it would fetch as is and the value that environment.username would return in ideal scenario

Hello @olgu
as per my understanding we can only save few type of assets in orch and one of them is String… the line of code you are trying to save is an Expression and not string.
Instead of split string you can use PlaceHolder.

e.g
value of asset in orch Assetvalue = “C:\Users\ {0}\Desktop\file.txt”
string path = String.format(Assetvalue,Environment.UserName)

6 Likes

This is normal from our experience. It’s a string type so it is all a string, not variables at all.

Solution is just store something like this in the asset:

C:\Users{Environment.UserName}\Desktop\file.txt

The get the asset in you project into a variable, then just do a replace activity - {Environment.UserName} with Environment.UserName

4 Likes

Thank you. It’s seems like a neat solution

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