- Cloud Deployment
- JPD
- I am admin of the project.
- Building an automation rule that tries to set the value of the custom field Duration (type: number) based on the difference between two custom fields: Project Start (type: date) and Project Target (type: date). While the rule runs successfully, I'm unable to get the right value.
- Tried to use different formula likes {{daysBetween(Project target, Project start)}} but unable to get anything meaningful.
If I add some debugging:
Debugging Duration Calculation:
Project Start: {{Project start}}
Project Target: {{Project target}}
Calculated Duration: {{daysBetween(Project target, Project start)}}
What I get in output is this:
Debugging Duration Calculation: Project Start: {"start":"2025-10-01","end":"2025-10-01"} Project Target: {"start":"2025-12-31","end":"2025-12-31"}
indicating that even though Project Start and Project Target are of type date, the include somehow a range.
I tried many different ways to parse (json parse, match) and try to get only one date out of the range, but I always get empty strings. {{Project start}} is simply evaluating to null or an empty string from the very beginning, before any .jsonParse, .match, or .toDate can even try to act on it.
How can I get to the date values inside the fields of type Date in JPD?
Hi @Lamija Pasalic -- Welcome to the Atlassian Community!
JPD date fields are JSON represented as text, and contain a single date or a range of dates. They must be converted for use as date types, such as using the jsonStringToObject() function:
For example, and assuming your smart values have IDs of customfield_12345 and customfield_67890, and each have a single date value, this would be the calendar days difference:
{{jsonStringToObject(issue.customfield_12345).start.toDate.diff(jsonStringToObject(issue.customfield_67890).start.toDate).days}}
UPDATE: After a quick test, it appears the custom field ID values must be used for the syntax I showed. Please identify the ID values using this how-to article:
https://support.atlassian.com/cloud-automation/docs/find-the-smart-value-for-a-field/
Kind regards,
Bill
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.