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
Posted yesterday in Jira Service Desk

Looking for anyone who has switched from Zendesk to Jira Service Desk

Hi Community! The Jira Service Desk marketing team is looking for customers who have successfully switched from Zendesk to Jira Service Desk!   We’d love to hear your thoughts on the pros and ...

30 views 0 1
Join discussion

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