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

Corinna March 16, 2016

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
Vasiliy Zverev
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 16, 2016

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

Corinna March 16, 2016

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

2 votes
Nicolas Bourdages
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 16, 2016

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.

 

Corinna March 16, 2016

"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

Nicolas Bourdages
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 16, 2016

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.

0 votes
Jeremy Gaudet
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 16, 2016

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).

MAG-II June 21, 2019

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?

Jeremy Gaudet
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 24, 2019

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())
}
}
MAG-II June 25, 2019

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?

Jeremy Gaudet
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 9, 2019

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
MAG-II September 9, 2019

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