You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.
View groupJoin the community to find out what other Atlassian users are discussing, debating and creating.
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) }
----------------------------------------------------------------------
----------------------------------------------------------------------
thanks,
JY
Though this is working when I modify/update the 'Initiative Link' field in the existing issues, but not working when I create a ticket having the same 'Initiative Link', also I need this to remove if existing any '12030 ' issue link and add updated Initiative Link.
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.issue.IssueEvent
def issueLinkManager = ComponentAccessor.getIssueLinkManager()
def issueManager = ComponentAccessor.getIssueManager()
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def long tpIssueLinkType = 12030 // Initiative Issue Link
def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
CustomField customField = customFieldManager.getCustomFieldObject("customfield_14771") // Initiative Link Field
Issue sourceIssue = issueManager.getIssueByCurrentKey(underlyingIssue?.getKey()) // Get Underlying issue key
sourceIssue.getCustomFieldValue(customField).each {
iscr ->
def cfIssue = issueManager.getIssueByCurrentKey((String)iscr)
issueLinkManager.createIssueLink(cfIssue.id, sourceIssue.id, tpIssueLinkType, 1L, currentUser)
}
If you already heard about Smart Commits in Bitbucket, know that you just stumbled upon something even better (and smarter!): Genius Commits by Better DevOps Automation for Jira Data Center (+ Server...
Connect with like-minded Atlassian users at free events near you!
Find an eventConnect with like-minded Atlassian users at free events near you!
Unfortunately there are no Community Events near you at the moment.
Host an eventYou're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.