Setting the due date

Irina Solarcuka May 22, 2013

Hi,

I'm junior in JIRA. Could somebody help to resolve the following task?

I need to preset the due date=creation date+3 days for one project.

Irina

2 answers

1 vote
Nadir MEZIANI
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.
May 22, 2013

Hi,

I think You can do it using a script in the post function JJUPIN or JPython.

Or in the screen transition in javascipt

Irina Solarcuka May 22, 2013

Thanks,

As a "screen transition" do you mean transition's post function. Have you got any script example?

Nadir MEZIANI
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.
May 22, 2013

Hi,

There are some transitions that have no screen, so we use some scripts in the post-transition function as JJUPIN or another scripting plugin (#{dueDate}=#{created}+3d)

With javascript , you put this script in your description field duedate

var bb = new Date();
var cc = new Date();
cc.setDate(bb.getDate()+3);
calendar.setDate(cc);
calendar.callHandler();


0 votes
Zul NS _Atlassian_
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 22, 2013

Hey Irina, seems like there has been a discussion on this before. You can get it to work using Behaviour Plugin. You can read more about it in here.

Irina Solarcuka May 22, 2013

Thank you! A little bit more...

I've tried to run this script:

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("Kritiska")){

cal = getDate(CRITICAL);

} else if(priority.equals("Augsta")){

cal = getDate(MAJOR);

} else if(priority.equals("Vidēja")){

cal = getDate(MINOR);

} else if(priority.equals("Zema")){

cal=getDate(Trivial);

}

Timestamp dueDate = new Timestamp(cal.getTimeInMillis());

mutableIssue.getPriorityObject();

mutableIssue.setDueDate(dueDate);

but in the log file I've found the following:

2013-05-23 17:35:33,892 http-bio-8080-exec-12 ERROR isolarcu 1055x7733x1 1aixvvg 46.109.227.104 /secure/QuickCreateIssue.jspa [onresolve.jira.groovy.GroovyFunctionPlugin] Error executing post-function

javax.script.ScriptException: javax.script.ScriptException: java.lang.NullPointerException: Cannot invoke method getTimeInMillis() on null object

at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:117)

Zul NS _Atlassian_
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 22, 2013

In the discussion link I've provided above, discussed about the similar error as well. You can scroll down a bit or try CTRL+F for "Cannot invoke method getTimeInMillis() on null object" on the link.

Suggest an answer

Log in or Sign up to answer