Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Trouble commiting DueDate after setting it with groovy/script runner

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 Leader Feb 04, 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 

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

Suggest an answer

Log in or Sign up to answer
TAGS

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you