we need the "Need By date" field to auto populate while creation of subtask and its field value to be 5 days prior from the "Original due date" field value present in the parent task.
Are the subtasks created by some sort of existing automation? If so, can you share what you have so far?
Or are these manual subtasks created by the user via the UI and you only need to automate the date field?
If so, do the parent task and the sub-task share the same workflow? Or are they different workflows?
You should be able to copy the date from the parent in a postFunction on the Create transition for the sub-task workflow.
If you have a recent version of scriptrunner, you don't even need a script. You can just use the "copy field values" feature. Never mind that ... it won't work because of your need to have 5 days before
If you really want to use a script, it would look like this
def originalDueDateCf = ComponentAccessor.customFieldManager.getCustomFieldObjectsByName('Original due date')
def dueDateCf = ComponentAccessor.customFieldManager.getCustomFieldObjectsByName('Need By date')
def originalDueDate = issue.parent.getCustomFieldValue(originalDueDateCf )
Hello Atlassian Community! Feedback from customers like you has helped us shape and improve Jira Software. As Head of Product, Jira Software, I wanted to take this opportunity to share an update on...
Connect with like-minded Atlassian users at free events near you!Find an event
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no Community Events near you at the moment.Host an event
You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events