Error in getting the current date from Orchestrator asset

Hello Everyone,

The issue is : I can’t able to get the current date value form orchestrator asset.
I have a asset in which the text value is = Date.now.tostring(“dd-MM-yyyy”)

When I run the program, I get the exact text as Date.now.tostring(“dd-MM-yyyy”) instead of the current date such as 26-05-2021

My Requirement is : I need current date to be entered in a website which I can hard code, But sometimes I need to enter different dates. Thus I have chosed Orchestrator assets.

I have been checking through out the forum & internet for many hours and I couldn’t able to find a solution. Please help me in this case. TIA.

Thanks and regards,
Sathanand

Hi @Sathanand

It does not work like this.

Assets can store Text, Integer, Bool and Credential types.

You are trying to evaluate a .NET code from the asset.

What you can do is set the date value like 2021-05-26 and in your code if the asset contains value you convert it to a date object using DateTime.Parse(yourAssetValue), otherwise, if the asset has a blank value, then you use DateTime.Now (hard-coded).

1 Like

@Sathanand,

@alexandretperez is right, it does not run on .Net compiler or executor.
Whatever you put in it give you.

You can write today date in config file instead of asset and get it from excel using Read Cell activity.

1 Like

Thank you both… @alexandretperez @Pankaj.Patil :slight_smile:
Now I feel free, As I was breaking my head that why I can’t find a direct solution for that.
But anyways, I have coded a workaround which is similar to @alexandretperez approach.

What I did is, Like you said add a blank value, I added Today in the text value of the asset, And an if condtion in my project to which it checks for the keyword Today. If found, the then part has the Date.now.tostring(“dd-MM-yyyy”) or it goes to the else which will fetch the asset’s date which is edited for the required date. :sunglasses:

2 Likes

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