Script field output different then the 'preview'

Karel Striegel April 21, 2014

Dear,

What I'm trying to do :

1. A ticket has a due date.

2. A ticket has a custom field defining the number of days it is allow to go over its due date

3. I'm trying to create a script field that add those days to the due date.

The script that I wrote (see below) is providing me the correct output when I add it to a script field and test it by running "a preview with issuee xxxx". But when the script field is saved the value that appears in the ticket does not match the value in the preview anymore. Every ticket also gets the same value (31/Dec/13 11:00)

Here is the script that I'm using :

/*
This is a script that adds the value in "Obsolete after X days overdue" to the due date of this field.
Version 1.0
  - 2014-04-16 : Initial draft
  

*/

import com.atlassian.jira.issue.CustomFieldManager;
import com.atlassian.jira.component.ComponentAccessor;
import java.sql.Timestamp;

System.out.println("MY TEST");
	
if(issue.getDueDate() != null){
	final long DAY_IN_MILLIS = 1000 * 60 * 60 * 24;
	CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager();
	int xdays = customFieldManager.getCustomFieldObjectByName("Obsolete after X days overdue").getValue(issue);
	def obsolete_date = new Timestamp((issue.getDueDate().getTime() + (xdays* DAY_IN_MILLIS)));

	return obsolete_date;
}
else {
	return null;
}

Kind regards
Karel.

5 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

1 vote
Answer accepted
JamieA
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.
April 22, 2014

This is due to a template change in the core product and has been fixed in more recent versions of SR. What version do you have?

See https://jamieechlin.atlassian.net/browse/GRV-342

JamieA
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.
April 22, 2014

> Anybody ?

Use the correct tags and you will get the right attention.
Karel Striegel April 22, 2014

We are using Jira version 6.1.6 and version 2.1.15 of script runner.
So based on your feedback it would seem that I need to update to version 2.1.16.

Thx for the feedback !

0 votes
Karel Striegel April 22, 2014

Update. It seems that the value is passed correctly but the displayed value is incorrect.

If I hover with the mouse over the field, I get the correct result. See screenshot.

0 votes
Karel Striegel April 22, 2014

Update. It seems that the value is passed correctly but the displayed value is incorrect.

If I hover with the mouse over the field, I get the correct result. See screenshot.

0 votes
Karel Striegel April 22, 2014

Anybody ?

0 votes
Karel Striegel April 21, 2014

A small correction regarding point nr 2. Is it not the number of days it is allowed to be open, but it is the number of days that it is allowed to pass its due date.

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

TAGS
AUG Leaders

Atlassian Community Events