Need help setting an absolute dueDate in Scriptrunner on a transition

I need help with setting up a transition post function to change the due Date of an Issue. I've added on Script runner as I get the impression that this is the only path possible to achieving what I want to.

Now not having any experience in Java/ Groovy, to say I am a noob would be putting it kindly, but I have had a first attempt at it anyway. Would this work?

def newDueDate = "31/03/2017"
			due: newDueDate
	.asString()"dueDate of " & newDueDate & "set successfully")

Note :: I just want to confirm that this is the correct approach as we only have a single instance of JIRA cloud, therefore any code I load will be going into the production environment and I would rather not mess this up.

1 answer

1 accepted

2 votes
Answer accepted

Hi @Brendan Clough,

There are only three small changes you need to make to that script.

First, the date should be in YYYY-mm-dd format.
Second, to join strings/text together you need to use the + symbol, not the &.
Third, the field is referenced as duedate, not due. 

def newDueDate = "2017-03-31"
def response = put("/rest/api/2/issue/${issue.key}")
            duedate: newDueDate
// If the request fails, this will print out a nice message in the logs
// showing you what the error response was.
// The 204 number here is the HTTP Status code for No Content, which is
// the documented response from this REST API
assert resp.status == 204"dueDate of " + newDueDate + "set successfully")

Feel free to ask if you have any more questions, or raise a support ticket - there is a link to our support portal from the Diagnostics & Settings page provided by the addon.


Awesome thanks mate! When an issue transitions, is it possible to determine what status it was in before the transition? Or what transition it is moving to?

Yes! You get a variable, transitionInput, in the script's context which contains this data:

When adding a Post Function, if you click on the ? button underneath the Code editor you'll get a popup dialog with a list of the variables that are already available in your script.

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Oct 09, 2018 in Jira Core

How to manage many similar workflows?

I have multiple projects that use variations of the same base workflow. The variations depend on the requirements of the project or issue type. The variations mostly come in the form of new statuses ...

369 views 6 0
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