I have a ScriptRunner Scripted field (called Parent Due) on my sub-tasks where I want to show the parent's due date.
Here is my script:
/* Displays the parent's due date. Applicable Sub-Tasks and Financial Sub-Tasks. */ import com.atlassian.jira.component.ComponentAccessor import com.atlassian.core.util.DateUtils // get the current issue's parent def subTaskManager = ComponentAccessor.getSubTaskManager() def parent = issue.getParentObject() def due // if current issue does not have subtasks, use the issue's remaining estimate and time spent if (parent != null) { due = parent.getDueDate() return new Date(due.getTime()) } else { return null }
The server time is Central time zone and I am in Mountain. So parent's date is 30/Jun/17 and I am getting 29/Jun/17 11:00 PM as my result.
I really want to use the date in a JQL query such as ... "Parent Due" = endOfMonth(-1) so I need a date returned.
Hi Jenny,
I've tried to reproduce your issue. If I understand what you've said correctly, you are seeing a different due date on screen to what you are seeing that the server has produced? I have tried to reproduce this error with your script and I am unable to. I have even tried to change the timezone on the user profile and I still see the same due date.
Have you tried the JQL search? Are you seeing expected results from that?
Thanks so much Stephen for trying to reproduce. I'll try to add additional details so that maybe you can reproduce successfully:
Q; If I understand what you've said correctly, you are seeing a different due date on screen to what you are seeing that the server has produced?
A: The parent's Due date stored on the server is Fri Jun 30 00:00:00 CDT 2017 (Central time) and I see 30/Jun/17 in the parent's Due date field. My computer & user profile is set to MT (Mountain time).
For the Parent Due field, I see 29/Jun/17 11:00 PM on the screen but when I hover over it, a little hover display shows me 30/Jun/17 12:00 PM (see screen print below). This makes me think it is stored correctly but showing incorrectly.
fyi ... I have my template and searcher set to be Date Time pickers.
Q: Have you tried the JQL search? Are you seeing expected results from that?
A: Yes, I have tried the JQL search. If I add a Due date to the sub-task, then my query Due = endOfMonth(-1) returns the record but if I try Parent Due = endOfMonth(-1) does not return the record.
So really my end goal is really to not have to maintaing a due date on all the sub-task records as it will be the same as the parent's due date. But I need to query all the sub-tasks for a certain month, so I need the date. Any other sugguestions are welcome. Thanks!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey Jenny,
Thanks very much for the clarification. I think you might be able to do this in a simpler way, that better suits your needs by using the subTasksOf scriptrunner function.
So I ran the following query:
issueFunction in subTasksOf("Due = endOfMonth(-1)")
This will return you all subtasks of the issues returned by the specified query.
This should give you the desired results without the need for the script field.
Does this work for your scenario?
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.
Hey Jenny,
I am glad to hear your issue is resolved :-)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.