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

3 votes
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

Nice work Nick - how far off is the if/else branching? Just evaluating the Automation AddOn for this exact use-case, but with priority defined within a custom field, where we're using the Compare2Values condition.

Nick Menere Community Champion Jul 10, 2018

Hi Brian,

 

We released if/else earlier in May.

You can read this at - https://blog.codebarrel.io/the-votes-have-been-counted-else-if-has-shipped-a8b1d3eb28cf

 

Reach out if you need me to help you through it.

 

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
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Jul 10, 2018 in Marketplace Apps

If you’re an Atlassian app developer, you’ll want to know about Atlas Camp!

This September 6-7, hundreds of Atlassian App developers will flock to Barcelona Spain to build skills, discover product roadmaps, meet face-to-face with the Atlassian team, and learn how to extend t...

179 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