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!

3 answers

1 accepted

This widget could not be displayed.
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

This widget could not be displayed.

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

This widget could not be displayed.

Hello,

I tried this solution and in the Audit Log it's showing status as "Success" but my "Due Date" field is still blank on the newly created tickets. Can anyone give me any advice as to why this is happening?

Thanks!

Olivia

I just realized my mistake and it is now working great!

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Aug 22, 2018 in Marketplace Apps

How a Marketplace app tech team is achieving gender diversity

Hello! My name is Genevieve Blanch, and I'm the Marketing Manager at RefinedWiki, creators of apps to give teams the tools to customize Atlassian platforms. Currently, 44% of the tech team at Re...

492 views 3 18
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