You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
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?
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
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello @Will C
This is a possible duplicate
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.
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.