Typing Assets that contains VB expression and variable

I have created an Asset that is a file path to be typed into windows explore to save a generated file. The file path contains the expression “now.AddDays(-DaysBack).ToString(“MM-dd-yyyy”)” to add a date to the name of the file. The date to be added is determined by the value of the DaysBack variable. When running the script with the file path as an asset it types out the file path with the expression and variable verbatim. Is there anyway to get the file path to include the expression and variable correctly when using an asset to store the file path or is best to leave it hard coded into my xaml file?

Hi,

I don’t think you can use vb.net directly, however you can use keywords so you can use .Replace.

So, if your asset is something like… “text MM-dd-yyyy”
In your script you put…
dateVar=Now.AddDays(-1*DaysBack)
variable.Replace(“MM”,dateVar.ToString(“MM”).Replace(“dd”,dateVar.ToString(“dd”).Replace(“yyyy”,dateVar.ToString(“yyyy”))

or, if your asset uses a different word like… “text DATE”
variable.Replace(“DATE”,Now.AddDays(-1*DaysBack).ToString(“MM-dd-yyyy”))

Hope this helps. You can also use this method with configuration text files if you choose to store your assets there.

Regards.

Thanks! Would I put the expression with the keywords as the output value of the asset?

Yes. So to clarify,
You put in the output value of your Asset the text you would like but use words that can be replaced later in your script, so you can make it more dynamic.

Like, “text MM-dd-yyyy” … “MM” would represent the month that you will replace in your script, and same with “dd” and “yyyy”. And, you can use any words really. For example, “text DATE” … “DATE” would be a word that you replace in your script which will be the date you are using.

Regards