I use the following code to clone an issue:
def params = [
(CloneIssue.FIELD_TARGET_PROJECT): "my project key",
(CloneIssue.FIELD_LINK_TYPE) : null,
......] as Map<String, Object>
def executionContext=[ issue : mySourceIssue ] as Map<String,Object>
def cloneIssueBean=ScriptRunnerImpl.scriptRunner.createBean(CloneIssue)
def updateContext = cloneIssueBean.execute(params, executionContext)
That will clone my issue with all the links including "cloners". My question: How do I indicate specific link type s through the param FIELD_LINK_TYPE since I don't want all the links to be cloned? I don't want to clone the "cloners" type. I tried to put in link type ids as Long, String, List and none of them works. I can't eliminate cloners type from being cloned. All links are cloned. If we can't indicate the link types, what's the purpose of that parameter? I assume I just don't know what the format/syntax of that field.
Thanks,
Hi @Ha B_
the FIELD_LINK_TYPE
parameter is used to specify the type of link to be created between the original and cloned issues, not to filter which existing links should be cloned. This is why specifying different link type IDs or names in FIELD_LINK_TYPE
isn't working as you expected.
Instead you can first Clone the issue without links and then Recreate only the specific links you want by manually copying them, excluding the "cloners" links.
def clonedIssue = updateContext?.get("issue")
// Copy only non-"cloners" links
issueLinkManager.getOutwardLinks(mySourceIssue.id).each { link ->
if (link.issueLinkType.name != "Cloners") {
issueLinkManager.createIssueLink(
clonedIssue.id,
link.destinationId,
link.issueLinkType.id,
null,
ComponentAccessor.jiraAuthenticationContext.loggedInUser
)
}
}
issueLinkManager.getInwardLinks(mySourceIssue.id).each { link ->
if (link.issueLinkType.name != "Cloners") {
issueLinkManager.createIssueLink(
link.sourceId,
clonedIssue.id,
link.issueLinkType.id,
null,
ComponentAccessor.jiraAuthenticationContext.loggedInUser
)
}
}
Thanks @Tuncay Senturk .
How do I set the params to "NOT" clone the links? Sorry, I can't find any example or documents for it.
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.