Hello Atlassian Experts,
I have a requirement where , the due date field should be automatically updated with the priority value provided.
After going through lots of post related to this in Atlassian Community, I came across a script (adding below) that can serve this purpose .
import java.sql.Timestamp import com.atlassian.jira.issue.MutableIssue // initializing the priority def BLOCKER = 1; def CRITICAL = 2; def MAJOR = 3; def MINOR = 9; def Trivial = 30; // calender which returns the date according to the priority defined private GregorianCalendar getDate(double roll){ Calendar cal = Calendar.getInstance(); cal.setFirstDayOfWeek(Calendar.MONDAY); cal.set(Calendar.HOUR_OF_DAY,0); cal.set(Calendar.MINUTE,0); cal.set(Calendar.SECOND,0); cal.set(Calendar.MILLISECOND,0); for (int x=0;x<roll;x++){ cal.add(Calendar.DAY_OF_MONTH,1); } return cal; } MutableIssue mutableIssue = (MutableIssue) issue; def priority = mutableIssue.getPriority().getString("name"); def setDueDate = mutableIssue.getDueDate(); //only set the dueDate if the date isn't already set (i.e. if it == null). GregorianCalendar cal; if(priority.equals("Critical")){ cal = getDate(CRITICAL); } else if(priority.equals("Major")){ cal = getDate(MAJOR); } else if(priority.equals("Minor")){ cal = getDate(MINOR); } Timestamp dueDate = new Timestamp(cal.getTimeInMillis()); mutableIssue.getPriorityObject(); mutableIssue.setDueDate(dueDate);
But I am facing an error in the for loop for (int x=0;x<roll;x++){
cal.add(Calendar.DAY_OF_MONTH,1);
Error: 3 expression are required in classic for loop, you gave 4.
I am a newbie in javascript can anyone please help me out.
Thanks ,
Kartik
Hi Kartik,
You have copied in the encoded less-than symbol. Instead of:
for (int x=0;x<roll;x++){
You should have:
for (int x=0;x<roll;x++){
You'll notice the fix is to switch out < for <
I hope this helps!
Steve
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.