Setting the due date

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

This widget could not be displayed.

Hi,

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

Or in the screen transition in javascipt

Thanks,

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

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


This widget could not be displayed.

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.

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)

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
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted Wednesday in New to Jira

Are you planning to trial, or are currently trialling Jira Software? - We want to talk to you!

Hello! I'm Rayen, a product manager at Atlassian. My team and I are working hard to improve the trial experience for Jira Software Cloud. We are interested in   talking to 20 people planning t...

83 views 1 0
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you