Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,369,333
Community Members
 
Community Events
168
Community Groups

CreatingLink using Issue Link field (Inward/Outward Link)

Edited

Hi Team,

I have IssueType called 'Initiative' & 'EPIC', whenever I create an EPIC I will link Initiative using Issue link picker field type 'Initiative Link', as part of this process I want to link the same issue whatever I selected as 'Initiative Link' to be linked to my EPIC as 'child of' & same should be viewed in the issue link section of 'Initiative' with 'parent of' relation, in attempt to do this, I have created behavior for the field 'Initiative Link', so whenever this value is selected during create/Edit, it should update the issue-links with the same issue selected.

I have written the code like this, but I get an error when I run in console & same is not working in behavior too, not having any compilation error though but get some run time error
---------- 'org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object 'ABC-1617' with class 'com.atlassian.jira.issue.IssueImpl' to class 'java.lang.Long'
at Script784$_run_closure1.doCall(Script784.groovy:16)
at Script784.run(Script784.groovy:14)' ---------------

My code is
---------------------------------------------------------------------
---------------------------------------------------------------------
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.component.ComponentAccessor
def issueLinkManager = ComponentAccessor.getIssueLinkManager()
def issueManager = ComponentAccessor.getIssueManager()
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def jiraAuthContext = ComponentAccessor.getJiraAuthenticationContext()
def long tpIssueLinkType = 12030
def MutableIssue cfIssue
def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
CustomField customField = ComponentAccessor.getCustomFieldManager().getCustomFieldObject("customfield_14771")
Issue issue = issueManager.getIssueByCurrentKey("ABC-1703")
issue.getCustomFieldValue(customField).each

{ iscr -> cfIssue = issueManager.getIssueObject((Long)iscr) issueLinkManager.createIssueLink(cfIssue.getId(), issue.getId(), tpIssueLinkType, 1L, currentUser) }

----------------------------------------------------------------------
----------------------------------------------------------------------

Any help would be appreciated! 

thanks
AJ

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events