I would like to create a custom field that would work like the native linked issue functionnality.
I have scriptrunner so I guess it should be doable with a script listener but I am a noob.
I have a multi issue picker X (with a JQL that limits the search to EPIC of Project B) in a Project A, and when I pick one or several issue, I would like the reciprocity to be done in the other multi issue picker Y (with a JQL that limits the search to EPIC of Project A) in the other project B.
I know this addon could do the job (https://marketplace.atlassian.com/apps/1216498/easy-links-for-jira) but not sure it will be approved internally.
Not sure that Automation could do it, I think Script listener is the best ?
Any help about this is appreciated, thanks :-)
Hi there, not sure why would you want to do that rather than using the native Jira linking (where you can just create a new link) but you can try out something like below in Script Listener:
def user = ComponentAccessor.jiraAuthenticationContext.getLoggedInUser()
def field = ComponentAccessor.customFieldManager.getCustomFieldObject(10300) //10300 is my Issue Picker custom field ID
def issueA = ComponentAccessor.issueManager.getIssueObject('TEST-157') //issue in project A
// If you are using listener
// def issueA = event.issue
// Update the Issue Picker in Project B
def issueB = ComponentAccessor.issueManager.getIssueObject('ABC-123') //issue in project B
ComponentAccessor.getIssueManager().updateIssue(user, issueB, EventDispatchOption.DO_NOT_DISPATCH, false)
Over the years I've come to realize that Script Runner can do pretty much everything these days. At the same time though, if there is a plugin covering precisely what you are after (and seems supported and free at the same time), it might be worthwhile doing a bit of a verification of it first.
One problem by doing this with ScriptRunner could be maintenance -- you would be the sole responsible for making sure all of this works, and it would probably have to be done in a few different places.
So if I understood your situation correctly:
- you already have an Issue Picker field, which works totally fine as wanted
- this fields only stores a "one-directional" link though, let's say it holds a list of issue keys for simplicity, there's no actual issue link in the background, it's just a regular field on an issue
Now to get a bi-directional link with this setup, I would agree that a Listener sounds like the way to do it, that'd be my first thought as well. You probably would be fine by just listening to whenever the field's value changes, and when it does, get the issue keys from the changelog, and modify those issues' field to append the trigger issue in them, thus creating a somewhat bi-directional link.
Overall this should not be too difficult on paper, but there are still a few open things that come to mind:
- what is the business impact if this automation for some reason starts failing (in this case I would say due to version upgrades)
- what would be the cost/effort of maintaining this automation over time, ensuring it works with each upgrade of both ScriptRunner and Jira
- and will you always have a person capable of doing this maintenance, because this will require the person to understand the Jira ecosystem and know groovy
Whereas compared to having a plugin already doing this job, you are putting a lot of that maintenance aside, assuming that the plugin will just work fine as long as you don't mess up the supported version matrix between it and Jira. As it's supported, you can also contact the vendor to help/assist in case of any problems.
Other than that, Automation for Jira plugin might be capable of doing this as well (instead of SR listener), although I am a little more doubtful there - to make it work properly you might need the full paid version - there are quite some limitations in the free Lite version. I mean it basically works in a very similar way to SR Listeners, just a different interface.
Anyhow, my thoughts :)
If you do end up trying out the Listener some us groovy folks should be able to help out in case you get stuck somewhere.
Hello @Radek Dostál
thanks for your input but I already tried Automation paid/full version and it does not seem to accept the scriptrunner issue picker. Well I might have an old version but this instance is not opened on internet and updates are being done once or twice a year only.
Anyways could you please share the automation rule I should follow in this case, if I manage to update it some day ? :-)
Might have got desync'd there a bit, if what you have is a Script Field then that does not qualify as a regular field you can work with or automate -- it's value is just cached, but it isn't saved nor updated - it calculates and gets stored in the index when certain actions happen and that's it.
You would need an actual issue-picker which is created as a regular Custom Field - not a script field. (Well, can be any field type if it gets you to what issues you need to update.)
As for Automation for Jira I do not have an actual example, but I imagine something along the lines of:
- Scope: Project X
- When: Issue Updated
- If: "myField" value changed
- Then: Execute a groovy script (because you have ScriptRunner installed)
And you would need a groovy script because if the only reference to whatever issue you want to bi-directionally link back is just a custom field value, then you first need to get the field value, format it, and then do an actual per value (because it will be a collection of values, in case of multiple links). So that is not something Automation for Jira can do out of box, it would need to be scripted with ScriptRunner at least in my mind. Which, altogether, is just mixing 2 plugins together instead of just using a single one -- Script Listener - which would do the same job as a singular plugin dependency.
So the more that I look at it the Easy Links plugin seems like more and more of a better choice to try out first,
The functionality you are asking for is exactly what our app STAGIL Assets - Advanced Links offers (besides lots of other features).
It lets you create custom fields on both sides of the link that act as issue pickers that offer a variety of configuration options. They are also linked, so you can search for related issues with provided JQL functions even through more than one hierarchy level.
Check it out and feel free to let me know if you have any questions or reach out to us at https://support.stagil.com/.
Thank you for your reply but I will stick with Scriptrunner or automation that we already have or any other free addon :)
I tried https://marketplace.atlassian.com/apps/1216498/easy-links-for-jira?hosting=server&tab=overview Easy Links for Jira which is free but does not offer the reciprocity of links even if it does create the link between issues.
Got it :)
Our app actually creates reciprocal links in the background that do not show up in the issue links section (but also offers the option to use the available Jira link types that do show up there).
At least now you know that there is an option that you could use as a last resort ;)
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