简体   繁体   中英

Trouble commiting DueDate after setting it with groovy/script runner [JIRA]

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.util.Date
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()

What you are doing is correct but you need to commit your changes by calling IssueManager.updateIssue

import com.atlassian.jira.event.type.EventDispatchOption //add-this-line
import java.util.Date
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()

def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()//add-this-line

im.updateIssue(currentUser, issue, EventDispatchOption.DO_NOT_DISPATCH  , false) //add-this-line

You are setting the issue value correctly but you are not saving your changes

IssueManager.updateIssue will save any changes

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM