I would like to update the Parent Link when cloning a ticket. I added a script runner post function to clone a ticket. In the additional issue section, I added the following script:
import com.onresolve.scriptrunner.runner.util.UserMessageUtil
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
UserMessageUtil.success('Fieldwork Epic, created successfully.')
issue.summary = 'FieldWork: ' + sourceIssue.summary
def cf = customFieldManager.getCustomFieldObjects(sourceIssue).find {it.name == 'Issue Key'}
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def issueManager = ComponentAccessor.getIssueManager()
def parentIssue = issueManager.getIssueObject(cf) // Parent issue key here
def parentLink = customFieldManager.getCustomFieldObjectByName("Parent Link")
parentLink.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(parentLink), parentIssue),new DefaultIssueChangeHolder())
The script is not generating errors, the cloned issue is created successfully, however, the parent link field is not populated.
Note: Issue Key, is scripted field, containing the issue key of the Epics Parent
The cloned issue type is Epic.
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.