How to update due date based on ticket priority?

Hi,

I'm using Automation Lite for JIRA and JIRA Service Desk Server.  I was wondering if there was a way to set up a due date for a ticket based on priority set. 

For example,

  1.  Ticket is created.
  2.  Ticket priority is set by a helpdesk technician
  3.  If priority set to P2, set the due date +4 days from the current date

Thank you!

2 answers

1 accepted

1 vote
Nick Menere Community Champion Aug 29, 2017

Hey Samantha,

Using Automation for Jira it is dead simple and should take less than a minute or so to set up.

Create a rule with the following:

  • A "Issue created" trigger to listen for when issues are created
  • A "JQL condition" to check the issue has a priority of "P2". This can be extended to check for any other conditions.
  • An "Edit issue" action to set the due date setting the Due Date to "{{#now}}func=plusDays(4){{/}}"

You rule will look something like this:

Screen Shot 2017-08-30 at 9.31.47 am.png

The magic here is taking the date/time that the rule is run and adding 4 days to it. You can also use business days by using: "{{#now}}func=plusBusinessDays(4){{/}}"

 

Hope that is what you were after.

 

Cheers,

Nick

Hi Nick,

This is exactly what I was after! Is there a way to have multiple IF, ELSE statements. For example, IF P1 then X due date. IF P2 then Y due date within one automation rule? Or do they all need to be seperated?

Thanks!

Nick Menere Community Champion Aug 31, 2017

Hi Samantha,

You can either do it as seperate rules or you can do it in the same rule by "branching" on the current issue like this:

Screen Shot 2017-08-31 at 7.37.54 pm.png

We should be implementing if/else soon which will make it even simpler.

 

Cheers,

Nick

Hi Samantha

 

That's definitely doable if you have scriptrunner plugin installed on your jira instance.

 

here are the steps

 

1. remove due date field from the create screen/ customer portal(service desk) so that it should not be accidentally modified

2. configure scripted post function on the create transition and use below script

 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.MutableIssue
import com.opensymphony.workflow.InvalidInputException
import java.sql.Timestamp;
import com.atlassian.jira.issue.customfields.manager.OptionsManager
import com.atlassian.jira.issue.customfields.option.Option
import groovy.time.*
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.crowd.embedded.api.User

def customFieldManager = ComponentAccessor.getCustomFieldManager()
def issueManager = ComponentAccessor.getIssueManager()

MutableIssue mIssue = issue

def priority = customFieldManager.getPriority().getName()

Calendar cal = Calendar.getInstance();
def temp = cal.getTimeInMillis();
def add = 0;
def x = 1000*24*60*60L
def mydueDate = new Timestamp(cal.getTimeInMillis());

if (priority == "P0")
{
add = 2*x // number denotes days
temp = temp+add
mydueDate.setTime(temp)

mIssue.setDueDat(mydueDate)

def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
issueManager.updateIssue(currentUser, issue, EventDispatchOption.DO_NOT_DISPATCH, false)

}
else if (priority == "p1")
{
add = 4*x // number denotes days
temp = temp+add
mydueDate.setTime(temp)

mIssue.setDueDat(mydueDate)

def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
issueManager.updateIssue(currentUser, issue, EventDispatchOption.DO_NOT_DISPATCH, false)
}else{
add = 30*x // number denotes days
temp = temp+add
mydueDate.setTime(temp)
mIssue.setDueDat(mydueDate)

def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
issueManager.updateIssue(currentUser, issue, EventDispatchOption.DO_NOT_DISPATCH, false)

 

Let me know if you face any issues.

 

BR

Rahul

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Bridget Sauer
Published yesterday in Marketplace Apps

Calling all developers––You're invited to Atlas Camp 2018

 Atlas Camp   is our developer event which will take place in Barcelona, Spain  from the 6th -7th of   September . This is a great opportunity to meet other developers and get n...

62 views 0 4
Read article

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