Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Custom field value changes based on priority and status

Lakshmi CH
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.
September 27, 2021

Hi Team,

 We would like to implement the below automation, Could you please anyone help on this ?

 We have script runner, JMWE, JSU addons

When the status of the ticket is moved to approved with the priority of Critical the due date should be approved date +1 (approved date is a custom field)

example : So if I moved the status to approved today (9/27) and the priority is critical then the due date should = tomorrow or 9/28
ALSO, if a ticket is approved today ( 9/22) and the priority is NOT critical the due date should be today + 5 business days

2 answers

1 accepted

0 votes
Answer accepted
Suprija Sirikonda _Appfire_
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.
September 27, 2021

Hi @Lakshmi CH ,

You can achieve your requirement using Set field value post-function from JMWE

  • Add a Set field value (JMWE app) post-function on the Approve transition.
  • Select "Due Date" field, "Value type" as "Groovy Expression" and add the below snippet:
Date date(Date from, int nod){
Calendar c1 = GregorianCalendar.getInstance();
c1.setTime(from);

int weeks = nod/5;
int remDays = nod%5;

//Adding whole weeks
c1.add(Calendar.WEEK_OF_YEAR, weeks);

//Run a loop and check each day to skip a weekend
for(int i=1;i<=remDays;i++){
c1.add(Calendar.DAY_OF_MONTH, 1);
if (c1.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY)
c1.add(Calendar.DAY_OF_MONTH, 1);
if (c1.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY)
c1.add(Calendar.DAY_OF_MONTH, 1);
}

//Skip ending weekend
if (c1.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY)
c1.add(Calendar.DAY_OF_MONTH, 1);
if (c1.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY)
c1.add(Calendar.DAY_OF_MONTH, 1);

//move to 0:00
c1.clearTime();

return c1.getTime();
}

if(issue.get("customfield_11700")) {
if(issue.get("priority")?.name == "Critical")
return (issue.get("customfield_11700") + 1);
else
return date(issue.get("customfield_11700"),5)
}
  • Select the checkboxes under "Options" as per your use case.

Replace 11700 with the id of the approved date custom field.

Refer to this documentation which has a code snippet to add a certain number of days to a date excluding the weekends. 

 

We have opened a support ticket, https://innovalog.atlassian.net/servicedesk/customer/portal/8/SJMWE-2879 to better track your request. However, we couldn't add you as a reporter.  Please sign up using this link https://innovalog.atlassian.net/servicedesk/customer/portal/8/user/signup and share the user name/id. We'll then add you as the reporter and confirm. 

Thanks,

Suprija

Lakshmi CH
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.
September 28, 2021

Thank you @Suprija Sirikonda _Appfire_  for the quick response. Its working as expected. Thanks much again.

0 votes
Leo
Community Champion
September 27, 2021

Hi @Lakshmi CH,

you can try below snippet as post-function in Approved transition(should be placed in 1st position)

import java.sql.Timestamp

def d = new Date() as Timestamp
if(issue.getPriority().name == "Critical"){
d.setDate(d.getDate()+1)
}else{
d.setDate(d.getDate()+5)
}

issue.setDueDate(d)

I haven't tried this in my sandbox though

 

BR,

Leo

Suggest an answer

Log in or Sign up to answer