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.
Community moderators have prevented the ability to post new answers.
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?
> Anybody ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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 !
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Community moderators have prevented the ability to post new answers.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.