How to add number of days stored in a custom field

I want to calculate a date in the advanced section of a clone action. This is what I have now:

{
"fields": {
"parent": { "key":"{{triggerIssue.key}}" },
"assignee": { "name": "{{initiator.key}}" },
"description": "{{issue.fields.description}}",
"duedate": "{{#triggerIssue.fields.ETD}}func=plusDays({{issue.fields.customfield_10510}}),format=\"jiraDateTime\"{{/triggerIssue.fields.ETD}}"
}
}
       

The Due Date of the cloned issue should be calculated based on the date field ETD of the issue which triggered the rule and a number of days stored in the numeric customfield with id 10510 of another issue which is found based on a JQL related issue search. I am sure the issue object is right because the description is cloned ok.

Can anyone tell me if this is possible and if so what should be the right syntax to use here?

 

3 answers

0 vote
Nick Menere Community Champion Jul 24, 2017

Hey Retmer,

Thanks for trying out Automation for JIRA.

This can definitely be done.

I usually find in the situations when I am trying to debug I use the "Log action" to print out the relivent info.

E.g. I'd use this as a value in the Log field:

 {{triggerIssue.fields.ETD}} - {{issue.fields.customfield_10510}} - {{#triggerIssue.fields.ETD}}func=plusDays({{issue.fields.customfield_10510}}),format=\"jiraDateTime\"{{/triggerIssue.fields.ETD}}

 

This print out all the different parts to make sure that we know where it is failing.

I'm guessing that the format is wrong. Duedate does not use time so you can try the format "jiraDate".

Though if ETD is a just a date (no time) you should be able to leave off the format all together.

Also, I'd recommend changing the customfield_10510 to the name of the customfield as it is easier to understand.

Another recommendation would be to use the actual fields from the field selector and copy values where possble. You should be do all of these fields in there.

 

Let me know if you still are having trouble and paste teh output from that Log action.

 

Cheers,

Nick

Thanks Nick for your answer.

I added some log statements and did some further testing. It seems that the value for customfield_10510 (Resolution Period) resolves to '2.0' and that this value is not accepted by the plusDays function. This functions expects '2'.

Is there a way to transfer the numeric value of '2.0' to '2'?

Nick Menere Community Champion Jul 25, 2017

I am assuming this field is a Number Csutomfield.

 

I've had a play around with this and can't figure out a way to do this. I've raised a bug at - https://codebarrel.atlassian.net/browse/AUT-447

 

The only work around is to use a text customfield as this wont convert the 2 to 2.0

 

Cheers,

Nick

I already tried to use a text field for the custom field but still it seems that a variable in the plusDays function is not resolved.

 

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Tuesday in Marketplace Apps

If you’re an Atlassian app developer, you’ll want to know about Atlas Camp!

This September 6-7, hundreds of Atlassian App developers will flock to Barcelona Spain to build skills, discover product roadmaps, meet face-to-face with the Atlassian team, and learn how to extend t...

116 views 0 4
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you