Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,558,788
Community Members
 
Community Events
184
Community Groups

Behaviours - getting a subtasks parent DueDate

Edited
Will C
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.
Mar 25, 2019

Hi there,

 

I am trying to write a script that wont let you edit, create a subtask if the due date is further in the future than the parent issue.

I have searched on various old posts and thought I could do this by using

Jamie's example here - https://scriptrunner.adaptavist.com/latest/jira/recipes/behaviours/subtask-default-fields.html

or I have seen you can get the parent by using underlyingissue.parent or getparent()?

In the past in other areas of scriptrunner I can use issue.getParentObject

how can I get the parent due date so I can compare it to the child due date?

Can you also look at the below, I have changed this I am comparing custom fields on the same issue but ignore the script for now, is this in the right place? or should it be on the initialiser if I want to get it for parent duedate?

 

Behaviours.JPG

 

3 answers

1 accepted

1 vote
Answer accepted
Antoine Berry
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Mar 25, 2019

Hi,

If you simply need to compare the issue's due date to the parent's due date you can use this code (remember that you need to check that the issue is created and that the parent exists) : 

def dueDate = getFieldById("duedate").getValue()
if (underlyingIssue?.getParentObject()){
def parentDueDate = underlyingIssue.getParentObject().getDueDate()
}

You can then compare them : 

if (dueDate.compareTo(parentDueDate) > 0){

getFieldById("duedate").setError("The child due date value must be set prior to the parent due date")

}

Antoine

Will C
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.
Mar 25, 2019

thank you for the help with this, I take it that on edit issue that you can't use parentissueid field? that was the piece I was stuck on.

Like Antoine Berry likes this

I have a similar problem in that I want to populate the summary based on the parent summary and I want this to show during the create process to avoid confusion so a post-function is not suitable. The problem I have is that the underlyingIssue is not populated during create so I can't find the parent. Jira must know the parent issue when creating a sub-task but I can't seem to find a method to get at this.

0 votes
Tarun Sapra
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Mar 25, 2019

Hello @Will C 

This is a possible duplicate

https://community.atlassian.com/t5/Jira-questions/Limit-Duedate-of-Subtasks-based-on-their-Parents/qaq-p/678348

As far as configuration in behaviour is concerned, then your script should be mapped to the dueDate field in the sub-task for the field mapping.

Suggest an answer

Log in or Sign up to answer