I am trying to create a rule that automatically creates a set of sub-tasks when a story is created. Each Sub-task will have Target start and end dates created within the rule based off the target start and end dates of the story. For example if the story has a date difference of 90 days between the start and end dates the first sub-task will have dates that cover 10% of that, or 9 days.
I have a variable which calculates that 10%:
endDate
{{#=}}ROUND({{triggerIssue.Target start.toDate("yyyy-MM-dd").diff(triggerIssue.Target end.toDate("yyyy-MM-dd")).days*.1,0){{/}}
When I try to use this variable within a date calculation it doesn't work. When adding it to the audit log, for instance:{{now.plusDays(endDate)}}
the log is empty. {{now.plusDays(endDate.asNumber)}}
also doesn't work.
Does anyone know how to use a variable within a date calculation, or at the very least how to get a variable to function as a number?
If anyone searches this in the future, I reached out to Atlassian for this, and they responded that the new syntax Automation uses cannot do this. The old syntax can though. Here is the JSON snippet Atlassian gave me to solve my request
{"fields": {
"Target Start": "{{triggerIssue.Target Start}}",
"Target End": "{{#triggerIssue.Target Start.toDate}}func=plusBusinessDays({{endDate}}){{/}}"
}
}
JSON
Thanks for that information, Jeremy.
Did the support team indicate if this was a behavior of Jira Data Center automation rules or something else?
And what did they mean by "new syntax Automation"?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The syntax automation uses for Smart values apparently changed when Atlassian acquired Automation. I asked for documentation of the old syntax, but they said they didn't have any publicly available.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yup...they took down / removed public access to the old Codebarrel blog, documentation, and backlog some time after the Atlassian documentation pages went live.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Your expression to perform the date difference is missing the closing double-curly brackets }}
{{#=}}ROUND({{triggerIssue.Target start.toDate("yyyy-MM-dd").diff(triggerIssue.Target end.toDate("yyyy-MM-dd")).days}}*0.1,0){{/}}
When writing expressions like this, you may want to create them in a text editor which highlights matching brackets, parentheses, etc. in order to see them more easily. Then copy-and-paste them into the rule editor.
Next, created variables are text, and to use them as numbers you may add the asNumber conversion:
{{varMyVariable.asNumber}}
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.
My variable does have the closing }}. that was a transcription error.
The {{endDate.asNumber}} produces a null value instead of number as it should based off the documentation here:
Automation smart values - text fields | Cloud automation Cloud | Atlassian Support
it seems trying to convert a variable to a number isn't possible.
Even changing the variable to just be the number 9 and trying to add
{{now.plusDays({{endDate.asNumber}})}}
results in the error: Failed to get value.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
When inside a set of double-curly brackets, another set is not needed. Please try this:
{{now.plusDays(endDate.asNumber)}}
If that also does not help...
Please post an image of your complete automation rule and an image of the audit log details showing your rule execution. Those will provide context and may help explain what you are observing.
And, you appear to be using Jira Data Center. I recommend writing the following to the audit log to confirm the smart values contain what you expect:
Target start : {{triggerIssue.Target start}}
Target start toDate: {{triggerIssue.Target start.toDate("yyyy-MM-dd")}}
Target end : {{triggerIssue.Target end}}
Target end toDate: {{triggerIssue.Target end.toDate("yyyy-MM-dd")}}
diff value : {{triggerIssue.Target start.toDate("yyyy-MM-dd").diff(triggerIssue.Target end.toDate("yyyy-MM-dd")).days}}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
the suggestion:
{{now.plusDays(endDate.asNumber)}}
also produces a null value.
What's odd is that:
{{#if(endDate.asNumber.isEmpty)}}EMPTY{{/}} {{#if(not(endDate.asNumber.isEmpty))}}NOT EMPTY{{/}}
Returns NOT EMPTY, so there is something coming though - it's just not being shown in the audit log and it doesn't work in a date calculation.
I can't provide screenshots because our Jira is on a separate classified network not connected to the internt.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.