Can someone help me with the date algorithm to achieve the following

Yeah that works and it’s a good approach

you can use a JSON to store the dynamic date values for the From Date and To Date parameters. This will allow you to handle both previous and future dates in the same process.

First, define your JSON structure. You can create a JSON string like this

{ "status": "previous date", "fromDate": "last dispatcher run date", "toDate": "current date - 1" }

Now, if the status is “future date,” you can set it like this

{ "status": "future date", "fromDate": "current date", "toDate": "current date + add days" }

In your UiPath process, create input parameters for status, fromDate, and toDate. You can pass the JSON string as the value for the status parameter.

Once you have constructed the JSON, you can pass it to the process as an input parameter. In the process, you can use the status property to determine which date values to use.

Something like this

`' Get the JSON input parameter
Dim json As String
json = InputParameters("json")

' Deserialize the JSON into a C# object
Dim criteria As New Criteria()
criteria = JsonConvert.DeserializeObject(json, criteria.GetType())

' Get the date values from the C# object
Dim fromDate As Date = criteria.FromDate
Dim toDate As Date = criteria.ToDate

' Use the date values in the process`

Hope this clarifies

Cheers @Ragavi_Rajasekar

1 Like