Set start date based on the FixVersion start date and the end date based on the estimate

Lean Li
Contributor
October 25, 2024

I have two custom fields:

  • Planned start date (customfield_121)
  • Planned end date (customfield_120)

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!

3 answers

1 accepted

1 vote
Answer accepted
Trudy Claspill
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 25, 2024

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}}

Trudy Claspill
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 28, 2024

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.

Like Bill Sheboy likes this
Lean Li
Contributor
October 29, 2024

I updated the automation a bit, but this is how it is as a whole:

automatio_rule.GIF

 

And the updated audit log looks like this:

AuditLog.GIF

 

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.

config.GIF

Lean Li
Contributor
October 29, 2024

And ignore the name of the automation in my dev environment - it is missleading:)

Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 29, 2024

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.

Like Lean Li likes this
Lean Li
Contributor
October 29, 2024

Thank you so much! I got this working with the custom field id values. 

Like Bill Sheboy likes this
0 votes
Lean Li
Contributor
October 28, 2024

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:

 automatio_rule.GIF

Edit Issue:

editIssue.GIF

 

Audit log:

AuditLog.GIF

In the automation, I am adding these values to Audit log:

  • {{TimeTrackingDays}}
  • {{issue.timetracking.originalEstimateSeconds}}
  • {{TimeTrackingDays.asNumber}}
  • {{issue.customfield_12100.value}}
  • {{issue.Target start}} 
  • {{issue.Target end}}
  • {{issue.Target start.plusBusinessDays(TimeTrackingDays)}}
  • {{issue.Target start.plusBusinessDays(TimeTrackingDays.asNumber).jiraDate}}
  • {{issue.Target start.plusBusinessDays(TimeTrackingDays.asNumber).jiraDate}}
0 votes
Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 26, 2024

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

Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 28, 2024

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.

Suggest an answer

Log in or Sign up to answer