UiPath Form Designer - How to Duplicate the Value of a Date/Time Component into Another Date/Time Component in a Data Grid Form on the Action Center?
Note: Sometimes in the Action Center it is necessary to create a Form with a Data Grid where the value of a Date / Time Component needs to be copied into another Date / Time Component.
In the below example, the value of the Start Date (with Field Key StartDate) which is a Date / Time Component will be copied into the End Date (with Field Key EndDate) which is also a Date / Time Component:
For the "End Date" to be updated with the same info that the one added in the "Start Date" it is necessary to add the following JavaScript code to the Logic of the "End Date":
The script checks if the "StartDate" field of the row exists (meaning it's not null or undefined) and if the "EndDate" field of the row is an empty string. If both these conditions are true, it sets the result variable to the value in "StartDate".
However, if either of these conditions is not met (meaning "StartDate" doesn't exist, or "EndDate" is not empty), it sets the result variable to false.
if(row["StartDate"] && row["EndDate"] === "")
{
result = row["StartDate"];
}
else{
result = false;
}
To add the above Logic follow the next steps:
- Click on the Edit button of the End Date.
- Click on the Logic section and click on Add Logic.
- Add a name to the Logic (for example Update End Date).
- On the Trigger section select the Javascript type, then add the code from above in the Text Area.
- Add an Action, name it (for example Set the Value) and select the type Value.
- Finally, add the below code in the Value section:
result = row["StartDate"]; return result;
After performing all the above steps save all the changes in the Edit section and then save the Form.
Once the project is saved and uploaded to Orchestrator it will work on Action Center as it works in Preview on UiPath Form Designer.