Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

ScriptRunner Post-function add 1 month to date field and update date field

Chris Ghazanchian
Contributor
March 24, 2018

I would like to add 1 month to a custom date field (Next Cycle Date) and then update that date field upon a workflow transition (post-function).

I have the current script but it's not doing anything, not sure what I am doing wrong.

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.UpdateIssueRequest
import java.text.SimpleDateFormat

CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager()

SimpleDateFormat dateFormatter = new SimpleDateFormat("dd/MMM/yy");
java.sql.Timestamp nextCycleDate = (java.sql.Timestamp)issue.getCustomFieldValue(customFieldManager.getCustomFieldObject("customfield_10603")) //get current "next cycle date"

nextCycleDate.setMonth(nextCycleDate.getMonth() + 1) //add 1 month to current cycle date to get next cycle date

issue.setCustomFieldValue(customFieldManager.getCustomFieldObject("customfield_10603"), nextCycleDate) //update next cycle date

 

1 answer

0 votes
Rhys Christian
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 10, 2016

Hey Tarun,

The behaviour you describe isn't correct behaviour for Initiatives. Could you please provide additional information so we can determine why Initiatives are disappearing for you?

Please explain how you've setup your initiatives and workflow. Does the "in-progress" status happen to be a "completed" status (i.e the status colour is green)? This may cause the issues to disappear because the default plan filter only shows completed issues that have been assigned to the current sprint.

Cheers,

Suggest an answer

Log in or Sign up to answer