Use Today’s Date in Calculations
To set up this configuration you need access to the Advanced Editor. If you don’t currently have access please talk to your system administrator or contact us at connect@rise-x.io
In this scenario, an employee is submitting a travel request. They must enter their intended travel dates. If the departure date is less than two weeks from today, an additional section will appear asking them to explain why the request is being submitted on short notice.
Step by step guide
- In the no code builder for a workflow or asset type add a date component and toggle on date range
- Also add in a toggle component
- This toggle component will be automatically toggled on when the travel request date is late
- Open up the advanced editor and copy the dataPaths for both the date and toggle component
- Inside the advanced editor add in a Data Pipeline
- Enter a value for the “name” property
- Inside the “watchPaths”: property add in:
- The data path of the date component (e.g. $.fillTravelDetails.travelDates)
- The data path of the date component + “.from” (e.g. $.fillTravelDetails.travelDates.from)
- This references the start of the date range
- The data path of the date component + “.from.date” (e.g. $.fillTravelDetails.travelDates.from.date)
- The whole structure should look like this
- Then click on the “IF” section
- Then click on the ellipsis next to the “AND” section
- Go to “Add Child” > “Condition”
- Change the “type” to “WORK_DATA_CONDITION”
- Inside the “payload”: {} property add in the “condition”: property and give it this value
- "'{$.fillTravelDetails.travelDates.from.date}' <> '' && Convert('{$.fillTravelDetails.travelDates.from.date:yyyy-MM-dd}', 'System.DateTime') < Convert('{$.now+2w:yyyy-MM-dd}', 'System.DateTime')"
- '{$.fillTravelDetails.travelDates.from.date}' <> '' checks if there is a date entered
- && tells the system to consider another condition and only come back as true if both conditions are met
- Convert() converts dates to the system date time format
- Convert('{$.fillTravelDetails.travelDates.from.date:yyyy-MM-dd}', 'System.DateTime') < Convert('{$.now+2w:yyyy-MM-dd}', 'System.DateTime') Checks to see if the start date entered is less than 2 weeks from today (this includes dates in the past)
- This example checks for 2 weeks ahead but this is the list of the timeframes that you can reference:
- now, now-1d, now-2d, now-3d, now-5d, now-1w, now-2w, now-1m, now-2m, now-3m, now-6m, now-1y, now+1d, now+2d, now+3d, now+5d, now+1w, now+2w, now+1m, now+2m, now+3m, now+6m, now+1y
- Then click on the ellipsis next the the “THEN” section
- Go to “Add Child” > “Operation”
- Change the “dataPath” value to the dataPath of the toggle (e.g. “dataPath”: “$.fillTravelDetails.lateBooking”)
- Change the “value” value to “true” (e.g. “value”: “true”
- The whole operations should look like this
- Then add another operation underneath the “THEN” section
- Change the “type” value to by “TRY_SAVE_DATA”
- Wait for the autosave and then delete the properties inside the “payload”: {} property
- Then add back in these two properties within the “payload”: {} property
- “jsonPath”: “”,
- “sectionName”: “”
- For the “jsonPath” add the dataPath of the toggle component
- For the “sectionName” find the task name that the component sits on and paste it in
- You can find the task name by navigating to the task in the advanced editor and then copying the value in the “name” property
- The whole operation should look like this
- Then on the “ELSE” section add in the same two operations, all the configuration should be the same as the operations in the “THEN” section with the only change being the the “value” should be equal to “false” in the “ELSE” section SET_JSON_PATH operation
- The whole data pipeline should look like this in the navigation panel of the Advanced Editor
- You have now set up the data pipeline so that when the start date that is entered is less than two weeks from today it will toggle the toggle component on
- You can then set up a conditional section based on the toggle component so that another section shows asking you to explain why the booking is late
- For more information about how to do this see this page on the knowledge base
{
"name": "14 Day Watcher",
"watchPaths": [
"$.travelRequest.travelDates",
"$.travelRequest.travelDates.from",
"$.travelRequest.travelDates.from.date"
]
}
{
"type": "SET_JSON_PATH",
"payload": {
"fallbackString": null,
"dataPath": "$.fillTravelDetails.lateBooking",
"value": "true",
"calculations": null
}
}
{
"type": "TRY_SAVE_DATA",
"payload": {
"jsonPath": "$.fillTravelDetails.lateBooking",
"sectionName": "fill travel details"
}
}