How to update due date based on ticket priority?

Sam Benacquista August 29, 2017

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

4 votes
Answer accepted
Nick Menere
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 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

Sam Benacquista August 30, 2017

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
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 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

Brian Hill July 9, 2018

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
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 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

P_D_ Foerster
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 1, 2019

A shame we don't have the Pro version :( So we cannot use the branching feature.

I'll have to stick to creating separate rules for that :/

0 votes
Olivia Snyder September 21, 2018

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

Olivia Snyder September 21, 2018

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

Miroslav Preradovic March 26, 2019

Hi Olivia,

Would you please share your solution?

I am having the same issue.

Thanks,

Miroslav

Olivia Snyder March 26, 2019

Hello Miroslav,

Here is the code I used in the "Edit issue fields" portion:

{{#now}}func=plusBusinessDays(5){{/}}

When I originally input the code, I had quotation marks around it, which is why mine was not working.

Hope this helps!

Thanks,

Olivia

Miroslav Preradovic March 26, 2019

Thanks Olivia!

I ended up using {{issue.created.plusBusinessDays(1)}} and it worked.

Unfortunately, I cannot get it to work with hours instead of days. For example, if an incident gets created at 11:00 AM on a Wednesday and my SLA is 8 hours, but my calendar counts only 8:30 to 17:00, I cannot get the due date set to tomorrow if I use {{issue.created.plusHours(8)}}. I don't think Automation for Jira takes into account my calendar. It just sets the due date for the same day.

It would be nice to have a bit more control over it, but I'll live :)

Cheers,

Miroslav    

0 votes
rahuldanwade
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 29, 2017

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
TAGS
AUG Leaders

Atlassian Community Events