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) { logger.info("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) { logger.info("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)) { logger.info("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
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
Posted Wednesday in Jira

Join our webinar: How 1B+ feature flag events helped us build the new Jira

Every time you release software, there's a bit of risk – that there's a bug, that something breaks, or that the feature doesn't resonate with customers. Feature flagging helps make high stakes s...

107 views 0 2
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