Forums

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

Script Help

Elif Alverson
Contributor
August 21, 2018

Hello, 

I have two questions about the script I am trying to use. 

Purpose: I would like to have issuetype = vulnerability tickets to have due dates based on the priority of a ticket when the ticket is created. 

If the ticket is blocker , due date +7 days from the creation date 

if the ticket is critical, due date +30 days from the creation date

if the ticket is major, due date +90 days from the creation date

1- how can I correct the error message below?

2-how can i add the issuetype of vulnerability to this script since script listener does not have a drop down box for it?

Thanks!

here is the script i used; 

 

import java.sql.Timestamp
import com.atlassian.jira.issue.MutableIssue

// initializing the priority

def CRITICAL = 7;
def MAJOR = 30;
def MINOR = 90;


// 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);

int numNonBusinessDays = 0;

for (int x=0;x<roll;x++)
{
if(cal.get(Calendar.DAY_OF_WEEK) == 1 ||
cal.get(Calendar.DAY_OF_WEEK) == 7) {
numNonBusinessDays++;
}

cal.add(Calendar.DATE, 1);
}

if(numNonBusinessDays > 0) {
cal.add(Calendar.DATE, numNonBusinessDays);
}

return cal;
}

 

image.png

3 answers

0 votes
Elif Alverson
Contributor
August 21, 2018

Here is the latest error message after I made the changes you have requested above; 

image.png

Markus
Contributor
August 21, 2018

"private GregorianCalendar getDate(double roll){

}"

Well a method of the type "GregorianCalander" can only return a "GregorianCalender" value. The value you are trying to return is only "Calendar" - wont work. 

 

If you are lucky changing:

"private GregorianCalendar getDate(double roll){"

to

"private Calendar getDate(double roll){""

 

will work but cant garuantee for that. 

Elif Alverson
Contributor
August 21, 2018

No error messages however script does not do anything. I created several tickets with Critical, Major and Minor priorities and due date is still empty. 

Anyways, thanks a lot for your help.

0 votes
Mark Markov
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 21, 2018

There are two errors in two lines

for (int x=0;x<roll;x++)

if(numNonBusinessDays > 0) 

Replace with

for (int x=0;x<roll;x++)

if(numNonBusinessDays > 0) 

0 votes
Markus
Contributor
August 21, 2018

if(numNonBusinessDays &gt; 0) 

should be ">".

Elif Alverson
Contributor
August 21, 2018

@Markus ,

which one ; 

if(numNonBusinessDays > 0)  OR

if(numNonBusinessDays gt > 0) 

Either way I have another error message, see below;

image.png

Markus
Contributor
August 21, 2018

You have exactly the same error:

(int x-0;x&lt;roll;x++)

Stands for "<". 

So:

&lt; = <

&gt; =>

Replace them with ">" or "<". 

Suggest an answer

Log in or Sign up to answer