Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How can I increment a custom field based on days elapsed since created date?

I have this script to calculate a custom field. I want to increment 'customfield_12331' by 1 as every 7 days go by. Is this possible?

def input1CfId = 'customfield_12326' def input2CfId = 'customfield_12327' def input3CfId = 'customfield_12328' def input4CfId = 'customfield_12329' def input5CfId = 'customfield_12331' def outputCfId = 'customfield_12330' def projectKey = "MS" if (issue == null || issue.fields.project.key != projectKey) {"Wrong Project ${issue.fields.project.key}") return } def input1 = issue.fields[input1CfId] as Integer def input2 = issue.fields[input2CfId] as Integer def input3 = issue.fields[input3CfId] as Integer def input4 = issue.fields[input4CfId] as Integer def input4 = issue.fields[input5CfId] as Integer if (input1 == null || input2 == null || input3 == null || input4 == null) {"Calculation using ${input1}, ${input2}, ${input3}, and ${input4} was not possible") return } def output = input1 + input2 + input3 + (input4/2) + input5 if (output == (issue.fields[outputCfId] as Integer)) {"already been updated") return } put("/rest/api/2/issue/${issue.key}") //.queryString("overrideScreenSecurity", Boolean.TRUE) .header("Content-Type", "application/json") .body([ fields:[ (outputCfId): output ] ]) .asString()


Thank you


 - Drew Nedderman 

0 answers

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Jira

Do you use Jira Cloud with Microsoft Teams?

Hi, Jira users! Do you use Jira alongside Microsoft Teams? We want to hear how you’ve used the power of Jira Cloud and Microsoft Teams (via the Jira Cloud for Microsoft Teams app) to achieve a team...

378 views 1 6
Read article

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you