When Sub-Tasks are created from a Story, I would like the parent Story's custom field value to be copied to the Sub-Task's custom field value. For example: I have a field named "Client" and I want the value to appear within the Sub-Task's "Client" field after the Sub-Task is created.
I am not interested in a paid add-on for JIRA and would like to use Script Runner instead.
I have tried to test my script below using the console, but am getting errors related to "issue" and "transientVars" not being understood.
Thank you for your help in advance!
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.MutableIssue
CustomFieldManager customFieldManager = ComponentManager.getInstance().getCustomFieldManager()
CustomField customField_name = customFieldManager.getCustomFieldObjectByName('Client')
def parentMyFieldValue = transientVars["issue"].getCustomFieldValue(customField_name)
issue.setCustomFieldValue(customField_name, parentMyFieldValue)