Hi All,
I am trying to add a remote link to an issue when I create it using the "Clones and links "script.
I have add the function callback to my Additional actions part of the script but it is never called. I have tried just setting basic fields to see that it is being executed but nothing ever happens. I even tried to use the example to add a link to an existing issue, pasted it and updated to match my existing issue and type. The only example given and it doesn't even pass the static checker!
So here is my code from the additional actions section - what am I doing wrong. Setting the custom date field works fine outside the doCreateAfter but does nothing inside.
I really want to just copy an external link from the creating issue to the cloned issue. At this point I would be happy just to see any proof that the doAFterCreate ever gets called.
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.link.RemoteIssueLinkBuilder
import com.atlassian.jira.issue.link.RemoteIssueLink
import com.atlassian.jira.issue.link.RemoteIssueLinkManager
import com.atlassian.jira.issue.link.IssueLinkTypeManager
def issueLinkTypeManager = ComponentAccessor.getComponent(IssueLinkTypeManager)
def issueManager = ComponentAccessor.getIssueManager()
def cfield = customFieldManager.getCustomFieldObjects(issue).find {it.name == 'LCM Phase'};
def fieldConfig = cfield.getRelevantConfig(issue)
def phase = "0"
def value = ComponentAccessor.optionsManager.getOptions(fieldConfig)?.find { it.toString() == phase }
issue.setCustomFieldValue(cfield, value)
issue.summary = sourceIssue.summary + ': Phase '+ phase +' Review'
// set the planned start date
def startfield = customFieldManager.getCustomFieldObjects(issue).find {it.name == 'Planned Start Date'};
def sourceStartField= customFieldManager.getCustomFieldObjects(sourceIssue).find {it.name == 'Phase ' + phase + ' Start Date'};
issue.setCustomFieldValue(startfield, sourceIssue.getCustomFieldValue(sourceStartField))
// set the planned end date
//def endfield = customFieldManager.getCustomFieldObjects(issue).find {it.name == 'Planned Finish Date'};
//def sourceEndField= customFieldManager.getCustomFieldObjects(sourceIssue).find {it.name == 'Phase ' + phase + ' End Date'};
//issue.setCustomFieldValue(endfield, sourceIssue.getCustomFieldValue(sourceEndField))
doAfterCreate = {
// set the planned end date
def endfield = customFieldManager.getCustomFieldObjects(issue).find {it.name == 'Planned Finish Date'};
def sourceEndField= customFieldManager.getCustomFieldObjects(sourceIssue).find {it.name == 'Phase 0 End Date'};
issue.setCustomFieldValue(endfield, sourceIssue.getCustomFieldValue(sourceEndField))
}