Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Editing Due Date with Automation for Jira

Andrew Syme
Contributor
June 9, 2020

I have a workflow with a frequency custom field (a number field) which records the number of months before the next task is due.

I want to use it to update the duedate field so

duedate = current due date plus F months

I thought this would work, 

{
"fields": {
"duedate": {{issue.duedate.plusmonths({{issue.frequency}})}}
}
}

 but I get an error

Error while rendering additional fields.

Failed to get value for issue.duedate.plusmonths({{issue.frequency

So it seems you can't embed smart values.

Any other ideas?

UPDATE:

I can do it with if/else blocks, but that means I need to change the logic every time I want a different frequency.

Annotation 2020-06-10 085411.jpg

2 answers

0 votes
Benoit
Contributor
January 8, 2021

I have similar issue. on the trigger of issue.fields.timeestimate value change, I want to adjust the issue.Target end by adding issue.Target start and issue.fields.timeestimate.

I tried many combination. If i use the now, it works, but as soon as i use issue.target start instread of now, it fails.

 

This works

{
"fields": {
"Target end":"{{#now}}func=plusSeconds({{issue.fields.timeestimate}}).toBusinessDay(){{/}}"
}
}

 

Is there any way to change a date field by adding two variable???

Thanks

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.
January 8, 2021

Hi @Benoit 

Please create a new question for topics like this.  That will help others in the community see it sooner and make solutions easier to find/search for.  Thanks!

Regarding your question, have you tried to first compute the value and put it in a Create Variable smart value?  You could then set that value to Target End.

Best regards,
Bill

Benoit
Contributor
January 12, 2021

Hi, Variables are available on cloud version only...

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.
January 12, 2021

Thanks for that information about your platform.  Note that when you create a new question the community can see what platform you are using, and so help with relevant ideas.

Your example JSON does not seem to match your request.  Have you tried something like the following:

{{issue.Target Start.plusDays( issue.fields.timeestimate.toDays() ).toBusinessDay()}}

Benoit
Contributor
January 12, 2021

First tanks for your support. But I am still struggling with this rules. There is no documentation I can refer. Another why your help is much appreciated. This is what I have so far:

{
"fields": {
"Target end":"{{issue.Target start.plusDays(issue.fields.timeestimate.toDays() ).toBusinessDay()}}"
}
}

 

Gives me an error: Error editing issuesTEST-1203 (Error parsing date string: (customfield_10207))

Where TEST-1203 is the edited task at fields.timeestimate

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.
January 12, 2021

Here is a link to the documentation for the server version of automation:

https://confluence.atlassian.com/automation/automation-for-jira-server-7-2-documentation-993924595.html

https://confluence.atlassian.com/automation/smart-values-993924860.html

Next, the error seems to indicate a problem with customfield_10207, so let's try to break this problem into pieces to see what is happening...

  • Before your field edit in the rule, add an Action to Log a message, then add one piece of that parsing.  For example: {{issue.fields.timeestimate}}
  • If that works, try adding a Action to Log for another part of it: {{issue.fields.timeestimate.toDays()}}
  • And so forth, keeping  this up until you see the error.

Using this method of progressively adding pieces to the audit log helps me diagnose what part of the automation syntax has the problem.

Benoit
Contributor
January 12, 2021

It is the conversion that is not working.

The issue.fields.timeestimate is in second. if I could just divide it by 28800 everything is fine, but even a simple division is not working.

"Target end":"{{issue.Target start.plusDays(144000/28800).toBusinessDay()}}"

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.
January 12, 2021

Gotcha...  Here is the documentation on the math functions:

https://confluence.atlassian.com/automation/working-with-numbers-993924632.html

Please try this for the conversion:

{{#=}}{{issue.fields.timeestimate}} / 28800 {{/}}

Benoit
Contributor
January 12, 2021

I have one finding, the issue.fields.timeestimate is in minutes in a working day. 480min/8h

This can be good to know...

But I tried what you suggest, but it can't be added inside the bracket'()'.

The things is that Advanced roadmap is not moving dates automatically. I am trying to achieve that with automation. so I just need to add the issue.fields.timeestimate with the target start to the Target end. prety basic, but i cannot do it. looks like the NOW is working, but not with any other field. I spent more than 3 days full time on that. I start to see {{smartvalues}} everywhere.

Documentation is very deficient for advanced stuff.

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.
January 12, 2021

Thanks for that additional information.  And, I agree that the documentation could be improved...definitely for more advanced usage cases.

There are two work-arounds for performing that math operation:

  • Add a custom field to save time estimate in days (e.g. TimeEstimateDays), and use another rule to update the custom field whenever the value changes.  Then you may use TimeEstimateDays directly in the JSON update.
  • Use an Entity Property to store the math calculation, and then Re-Fetch the issue to reload it in the rule's memory context.  This is even more complicated so I wouldn't recommend it.

Pausing on further changes, if you believe there is something broken with the Advanced Roadmap updating, I suggest submitting a ticket to Atlassian support to ask what they think: https://support.atlassian.com/contact/

Benoit
Contributor
January 12, 2021

Other finding... Target end and Target start are not date field. Therefore, date fonction wont work. They are string... Is it possible to confirm that?

I'll try a new way by converting the string to date and then do date function to add days, minutes or even seconds. Why is date in advance roadmap are not date field, but text field????

Benoit
Contributor
January 12, 2021

Other finding, Server Version do not allow .divide neither .multiply as a function.

Atlassian sucks honestly. I know they want to push for Cloud, but some company just can't go cloud and cannot afford datacenter. Just a huge amount of frustration. We decided to move to Jira just before the announcement. We would do it if we knew it.

Benoit
Contributor
January 12, 2021

as for now, I have one workaround: Create another custom field that are in days instead of seconds {{Estimation en jours}}. then use this formula:

{
"fields": {
"Target end":"{{issue.Target start.toDate("yyyy-MM-dd").plusBusinessDays(Estimation en jours)}}"
}
}

 

5 days of my life lost because of the lack of documentation from Atlassian and of course the lack of support for the server version. more over, having a date field recorded as a text in the database {{Target start}} and {{Target end}} that require to be converted.

One word resume it:

FRUSTRATED!!!!

Like # people like this
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.
June 9, 2020

Hi @Andrew Syme 

Did you try removing the inner set of braces?

{{issue.duedate.plusmonths(issue.frequency}}}

Best regards,

Bill

Andrew Syme
Contributor
June 10, 2020

Yes.  It's not valid

Error while parsing additional fields. Not valid JSON.

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.
June 10, 2020

Hi, and apologies, @Andrew Syme ... There does not appear to be a way to nest the values yet.  Here is the Code Barrel (now part of Atlassian) ticket for them to work on it:

https://codebarrel.atlassian.net/browse/AUT-168?page=com.atlassian.jira.plugin.system.issuetabpanels%3Aall-tabpanel

Although as you noted it is possible by editing the rule, not directly using your custom field. Maybe workflow and add-on script handlers can do it, if you have one.

 

How about this as a work-around: how many values are there for your custom field, Frequency?

If there are a limited number of values, you could use a create issue trigger (and/or edit to frequency) and use your if-if/else... structure to set the value.

Andrew Syme
Contributor
June 11, 2020

Thanks Bill, as per my update I've used If else blocks as there are only 3 frequencies at the moment but I would definitely want to have nested smart values to allow for various frequencies without having to keep the if/else blocks in sync.

Like Bill Sheboy likes this

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events