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))
}
Hello,
Do not use the doAfterCreate. Include the lines inside the do AfterCreate in your code:
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))
// 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))
Hi, thanks for the response. Yes the end date is outside after do create in my actual code. But I need to add a remote link to the new issue and it will not work outside of the doAfterCreate{} and doesn't do anything inside the callback. As far as I can tell doAfterCreate is never called.
I moved setting the custom field in to the doAfterCreate{} just so that I could verify that it is being executed. I also tried changing the summary and other fields. Nothing I do inside of doAfterCreate is ever executed.
So what I am trying to do is copy a remote link to a webpage from the source issue to the new issue.
I can put my code to copy the link into a separate post function and it will work there. But is very clunky, I have to go to my original issue, search through all of the links to figure out which issues are the right type and are new, get the linked issues, add the remote link.
But if I can do it from the clone issue all of the information I need is available, I know it is a new issue and the correct type so I just need the call to create the remote link. But this won't work until after the issue is created.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Did you try to log something in the doAfterCreate block with log.error("doAfterCreate")? Can you see these logs in the atlassian-jira.log file?
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.