Just a heads up: On March 24, 2025, starting at 4:30pm CDT / 19:30 UTC, the site will be undergoing scheduled maintenance for a few hours. During this time, the site might be unavailable for a short while. Thanks for your patience.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How to add number of days stored in a custom field

Retmer van Dongen
Contributor
July 24, 2017

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 votes
Retmer van Dongen
Contributor
July 26, 2017

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.

 

0 votes
Retmer van Dongen
Contributor
July 25, 2017

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
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.
July 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

0 votes
Nick Menere
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.
July 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

Suggest an answer

Log in or Sign up to answer
TAGS
atlassian, atlassian government cloud, fedramp, webinar, register for webinar, atlassian cloud webinar, fedramp moderate offering, work faster with cloud

Unlocking the future with Atlassian Government Cloud ☁️

Atlassian Government Cloud has achieved FedRAMP Authorization at the Moderate level! Join our webinar to learn how you can accelerate mission success and move work forward faster in cloud, all while ensuring your critical data is secure.

Register Now
AUG Leaders

Upcoming Apps & Integrations Events