Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How do i get the value of the "Issue" that is part of the "Linked Issues" field?

Hi

How do i get the value of the "Issue" that is part of the "Linked Issues" field:

jira-edit-issue-screen.PNG

 

My Groovy code for Jira Behaviours looks like:

import org.apache.log4j.Logger
import org.apache.log4j.Level

def log = Logger.getLogger("blah.blah.blah")
log.setLevel(Level.DEBUG)

def linkedIssuesCF = getFieldById("issuelinks")

def issueLinksCF = getFieldById("issuelinks-linktype")

log.debug "xxx1 linkedIssuesCF = (" + linkedIssuesCF + ")"
log.debug "xxx2 issueLinksCF = ( " + issueLinksCF + ")"

def bugid = getFieldById("issuelinks-issues-textarea")  // <<<--- Is this the right name?  If not, how do i get the value of this field???
log.debug "xxx3 bugid = (" + bugid + ")"

In my Groovy code, i will need to take some action based on field values of the issue key that the user specified in "Issue" field

This is what i see in the atlassian-jira.log file:

xxx1 linkedIssuesCF = (Form field ID: issuelinks, value: issuelinks)
xxx2 issueLinksCF = ( Form field ID: issuelinks-linktype, value: mitigates)
xxx3 bugid = ( Form field ID: issuelinks-issues-textarea, value: null )

2 answers

That field is only used for adding new links.

It doesn't store issue links as values, you should be able to see this by adding an issue link and then viewing the field on the Edit screen again. 

You should instead ask IssueLinkManager for the links.

def issueLinkManager = ComponentAccessor.getIssueLinkManager()
def innerLinks = issueLinkManager.getInwardLinks(issue.id)
def outerLinks = issueLinkManager.getOutwardLinks(issue.id)

List<Issue> relevantIssues = new ArrayList()

for(issueLink in innerLinks){
    relevantIssues.add(issueLink.getSourceObject())
}

for(issueLink in outerLinks){
    relevantIssues.add(issueLink.getDestinationObject())
}

relevantIssues should then hold a list of all linked issue objects. 

Thanks for the reply.

I need to know the issue that the user is trying to add so i can look up some info in that Jira issue.  If some condition is NOT met, then when the user clicks on the "Update" button, they cannot proceed.  The Groovy code should display an error message and prevent the user from adding new links if the issue the user is adding doesn't meet some criteria.

So my requirements cannot be achieved?

Thanks

--Andrew

 

 

 

Hi Andrew,

Did you have any success with the subject? 

Thanks and BR.

Viktor

Thanks for the follow-up.

But i've had no such luck.  :(

--Andrew

Hi Andrew,

I have found a way to achieve what I needed. 

I could refer to both of these FormFields like this:

FormField issuelinks = getFieldById("issuelinks")
FormField links = getFieldById("issuelinks-issues")

if (links.getFormValue()){
links.clearError()
//if only 1 link it is a string, if more - it is a list
String linkedIssues = links.getFormValue()
if (log.isDebugEnabled()) log.debug logPref + "Value " + linkedIssues.length()
}

Oh yeah, if you need to refer to that field in behaviour, you need to edit behavior (field id) after it's created:

<field id="issuelinks-issues" required="null" readonly="null" hidden="null" validator="server" 

Viktor

Thanks for your help.

Thanks

--Andrew

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Marketplace Apps & Integrations

Staying organized with Jira: best practices for a better project management

Project managers know this problem: A “mountain of work” lays in front of you, and you don’t know how and where to tackle them. Different to-dos lie ahead, but just one task after the other can be ha...

233 views 2 1
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you