Forums

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

Trouble commiting DueDate after setting it with groovy/script runner

Michael Edwards
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
February 3, 2020

Currently, we have routine issues where the status resets each week. This escalation service is working as intended. However, we are trying to incorporate the following script to adjust the system field 'DueDate' to be set for 7 days from the date when the escalation fires. The following code updates the date and returns the correct value but it doesn't appear to be committing the date of the provided ISSUEKEY.

Here is our code:

import java.sql.Timestamp
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.MutableIssue

def customFieldManager = ComponentAccessor.getCustomFieldManager()
IssueManager im=ComponentAccessor.getIssueManager()
MutableIssue issue = im.getIssueObject('ISSUEKEY')

issue.setDueDate(new Timestamp((new Date() + 7).time))
issue.getDueDate()

 

2 answers

0 votes
Leo
Community Champion
February 4, 2020

@Michael Edwards,

May I know where you are running this script?

 1. Post-Function?

  >>> If so check the order of post-function, it should be top of re-index post-function

2. Script Listener?

>>> if so you'll have to include "EventDispatchOption" method

def issueManager = ComponentAccessor.getIssueManager()

def appUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()

//place duedate update code here

issueManager.updateIssue(appUser, issue, EventDispatchOption.ISSUE_UPDATED, false)

 

Hope this helps

 

BR,

Leo 

Michael Edwards
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
February 4, 2020

Trying to run it in the build-in script as part of an escalation service. 

0 votes
Fernando Bordallo
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 3, 2020

Suggest an answer

Log in or Sign up to answer