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)
Hi @Lakshmi CH ,
You can achieve your requirement using Set field value post-function from JMWE
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)
}
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
Thank you @Suprija Sirikonda _Appfire_ for the quick response. Its working as expected. Thanks much again.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.