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

Is it possible to update fields of all linked issues of an issue if this main issue has field update ?

Hello , is it possible to update fields of all linked issues of an issue if I e.g. add a new Fix Version field to my main Issue......can I than automatically update this Fix Version value in all the linked issues to this issue........or can I make an SQL Query to get all the linked issues of certain issues ??

3 answers

1 accepted

1 vote
Answer accepted

For automatisation of update of all linked issues you will need some script. Namely you will need a listener on update issue event.

ok but this listener is not for free ? sure i have to pay a plugin ?

I would tend to favor a solution without scripting. Easier to maintain and quicker to setup. Your problem would be easy to do if the update happens on a transition of the source issue. You'll need to Misc. Workflow Extension plugin and use the Copy Field Value To Linked Issues post function

Since typically a field like Fix Version would be set when an issue is set Resolved or something similar, that solution would work I think. Or you could add a workflow transition from the status back onto itself and use the post function there. That would be your "edit and copy field value" transition and not actually change the status.

 

"Or you could add a workflow transition from the status back onto itself and use the post function there."–that would mean that i can make a transition without actually changing my status ? how can i do that ? i think the post function to update a field value i know already

In the workflow editor, in diagram view, you can literally make a transition arrow go from Status A to a different little white dot in the Status A. It looks like a loop, and that's a valid transition. You can even add a condition so that only certain users can see it, and a validator to make sure there's a value in Fix Version.

This "self transition" is a neat trick that can have other applications too. JIRA doesn't have field-level security, but you could use a transition like this to overcome that.

Let's say you want all users to view the Priority of an issue, but want to allow only managers to change it (or maybe the other way around, these pesky managers keep changing priorities for no reason smile). What you do is this:

 

  1. Create one screen that has the Priority field and use that as your View screen in the Screen Scheme.
  2. Make another screen that doesn't have Priority and use that as your Edit screen in the scheme
  3. Make a transition from a status onto itself and use the screen with Priority as the transition screen
  4. Apply a workflow condition on the transition to allow only the specific Managers group or project role.

This way, you get a "hidden" transition, accessible only to managers, to edit the Priority, preventing others from editing it.

High level, you can do both.  Syncing between parent/child (issue/subtask) or link/link is fairly straightforward.  I have an issue/subtask FixVersion sync Script Runner listener that updates the subtasks whenever the parent value is changed, or whenever the child value is changed (say, linking a new child that was out of sync, etc).  I posted a copy here:

https://answers.atlassian.com/questions/35775819

Beyond that, you can use the (again, Script Runner) issueFunction method in JQL to find such children.  For issue/subtask, you could use, for example:

issueFunction in subTasksOf("project=X and FixVersion=\"1.0\"")

This would get you all of the subTasks.  There is a similar function for links, "linkedIssuesOf", which takes a subquery like above, plus an optional link name.

For more specific help, we'd need to know how the parent/child relationship is modeled (issue/subtask, or specific outward/inward links, or custom fields, etc, etc).

Hi Jeremy - 

I was wondering if you could elaborate a bit with your example using ScriptRunner with how I can make a parent Issue's field automatically update the same field found in separate linked Issues. 

In my case I have an Issue that relates to 2 linked Issues in a "relates to (outward)" relationship. If I change a custom field on my main Issue I was hoping that the same fields found on the linked Issues would change as well. 

Is this possible via Listener configuration with ScriptRunner?

Yes.  The example I posted on the issue I referenced in my answer has a sample of a Parent/SubTask() sync.  You just have to change the line of code that gets the subtasks for the parent, and replace it with something that gets linked tickets of a particular link type.  The code you are replacing is:

Collection<Issue> subTasks = eventIssue.getSubTaskObjects(); 

So you probably want to create an array of issues, iterate through the links, and append each relevant linked issue to the array.  Something like:

import com.atlassian.jira.issue.link.IssueLink;
import com.atlassian.jira.issue.link.IssueLinkManager;

IssueLinkManager issueLinkManager = ComponentAccessor.getComponent(IssueLinkManager.class) as IssueLinkManager;
Collection<MutableIssue> linkedIssues = new ArrayList<Issue>();

for (IssueLink link in issueLinkManager.getOutwardLinks(eventIssue.id)) {
if (link.getIssueLinkType().getName()=="relates to") {
linkedIssues.add((MutableIssue)link.getDestinationObject())
}
}

Hey Jeremy - 

Thanks for the response! I tried to give the script you provided a whirl, as a Listener for Issue Updated events. I am getting errors on lines 5 and 9 though.

Line 5 tells me that it is not able to resolve class MutableIssue nor unable to resolve class Issue.

Line 9 tells me it is not able resolve class MutableIssue. 

Also, is there a place where I need to specify which custom fields I want to be linked together?

 

Any idea what I am doing wrong here?

You probably just have to import the missing classes.  Issue is listed in the linked sample, but I'll put both here:

import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.MutableIssue

Hey Jeremy - 

I appreciate the response. I've struggled through this situation all summer and still have not found the proper solution to link fields via ScriptRunner Listeners. I tried the script you provided, but I am still getting errors throughout.

 

In my project I have 3 different Issue Types. What I am trying to achieve is to have certain fields that are the same across all Issue Types to automatically update when one of the Issue's fields gets updated. The idea of fields being linked to one another doesn't seem intuitive to set up.

 

import com.atlassian.jira.issue.link.IssueLink;
import com.atlassian.jira.issue.link.IssueLinkManager;
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.MutableIssue

IssueLinkManager issueLinkManager = ComponentAccessor.getComponent(IssueLinkManager.class) as IssueLinkManager;
Collection<MutableIssue> linkedIssues = new ArrayList<Issue>();

for (IssueLink link in issueLinkManager.getOutwardLinks(eventIssue.id)) {
if (link.getIssueLinkType().getName()=="relates to") {
linkedIssues.add((MutableIssue)link.getDestinationObject())
}
}

 

 

Script.Errors.PNG

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Jira Service Management

JSM June Challenge #2: Share how your business teams became ITSM rockstars

For JSM June Challenge #2, share how your non-technical teams like HR, legal, marketing, finance, and beyond started using Jira Service Management! Tell us: Did they ask to start using it or...

314 views 9 7
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