I have two custom fields:
I want to create an automation that :
1. Updates the Planned start date to be the start date of the fixversion
2. Updated the Planned ednd date to be Planned start date + original estimate
The first requirement works well with this JSON to update Planned start date
{ "fields": { "customfield_121" : "{{issue.fixVersions.startDate.last}}" } }
BUT the second part ends in error "Error parsing date string", with this solution:
1. I have a variable "TimeTrackingDays", with smart value:
{{#=}}{{issue.timetracking.originalEstimateSeconds}} / (60 * 60 * 8){{/}}
2. I update the Planned end date (customfield_120) with this JSON:
{ "fields": { "customfield_120": "{{issue.customfield_121.value.plusBusinessDays(TimeTrackingDays.asNumber).jiraDate}}" } }
Any ideas on how to solve this and what is going wrong here?
Thank you alredy in advance!
Hello @Lean Li
I recommend that you start by confirming the values are what you expect them to be.
Use the Log action to write values to your rule execution log field. For example write the following values into your log:
{{issue.timetracking.originalEstimateSeconds}}
{{TimeTrackingDays}}
{{TimeTrackingDays.asNumber}}
{{issue.customfield_121.value}
{{issue.customfield_121.value.plusBusinessDays(TimeTrackingDays.asNumber)}}
{{issue.customfield_121.value.plusBusinessDays(TimeTrackingDays.asNumber).jiraDate}}
Please confirm that I have accurately noted the smart value you are logging, and the values that showed up in the log for each one.
smart value | value | |
1 | {{TimeTrackingDays}} | 4 |
2 | {{issue.timetracking.originalEstimateSeconds}} | 11520 |
3 | {{TimeTrackingDays.asNumber}} | null |
4 | {{issue.customfield_12100.value}} | null |
5 | {{issue.Target start}} | 2025-02-11 |
6 | {{issue.Target end}} | 2025-02-13 |
7 | {{issue.Target start.plusBusinessDays(TimeTrackingDays)}} | null |
8 | {{issue.Target start.plusBusinessDays(TimeTrackingDays.asNumber).jiraDate}} | null |
In your reply where you provided this information I see that you posted an image of your rule showing that you are using customfield_##### references in your JSON. The Log actions used "Target start" and "Target end". You should use the same customfield_##### references in your Log actions that you use in your JSON to ensure the log shows the values that correspond to the Smart Values you are using. It is also helpful if you add text to the Log action to indicate what is being logged, such as the smart value without the curly braces; i.e.
issue.Target end: {{issue.Target end}}
Text not in the curly braces will print explicitly in the logged message.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I updated the automation a bit, but this is how it is as a whole:
And the updated audit log looks like this:
Those field are "locked" and the Type in field configuration is " Target start" and "Target close". These custom fields are created and required by Portfolio for Jira.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
When editing the issue and using the math expression within the function call, please try using the divide() function rather than the / symbol...although I do not know if that is supported for Jira Data Center automation.
{
"fields" : {
"Target end": "{{issue.Target start.toDate.plusBusinessDays(issue.timetracking.originalEstimateSeconds.divide(28800)).jiraDate}}"
}
}
And, I recommend using the custom field id values for the two fields, Target end and Target start.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you for your answers, but I still don't get this working. The value in smart value TimeTrackingDays.asNumber seems to be "null" based on the Audit log entries (see screenshot below). Also the smart value with custonfield_12100 returns no value.
Here are the other screenshots. (Note, the customfield names are different here, as these are from my dev environment).
Rule details:
Edit Issue:
Audit log:
In the automation, I am adding these values to Audit log:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Lean Li
For automation questions, please include images of the complete rule, the action / condition / branch where you believe there is a problem, and an image of the audit log details showing the rule execution. Those will provide context for the community to help.
Until we see those...
What is the type for your Planned Start Date and Planned End Date fields? Are they date picker fields?
If so, please try this expression first:
{
"fields": {
"customfield_120": "{{issue.customfield_121.plusBusinessDays(TimeTrackingDays.asNumber).jiraDate}}"
}
}
If that does not help, these fields could be ones which only provide text values to rules. In that case, use this expression:
{
"fields": {
"customfield_120": "{{issue.customfield_121.toDate.plusBusinessDays(TimeTrackingDays.asNumber).jiraDate}}"
}
}
While trying these, ensure the name of the created variable and the name used in the expressions match exactly. Smart values are name, spacing, and case-sensitive, and when an unknown one us used that evaluates to null.
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.
Please try to stay within one thread when responding. That will help others reading this question in the future know if there are multiple possible answers. Thank you!
Would you please confirm: what are the types of those fields?
Next, please post an image of your complete rule, in one single image.
That will provide context relative to the audit log you are showing. (For longer rules, you may capture the rule in one image with a screen capture tool or a browser addon that supports scrolling page capture.)
Finally, created variables are text and it would appear that the function asNumber is not working in your version of Jira automation. Perhaps try the complete expression you use to create that variable in place of the variable. That will eliminate the need for conversion from text to a number for the parameter in the date increment.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.