Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

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

Create a custom field issue picker in 2 projects, working like a linked issue

Hello,

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

3 answers

1 accepted

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: 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.type.EventDispatchOption

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
issueB.setCustomFieldValue(field,issueA)
ComponentAccessor.getIssueManager().updateIssue(user, issueB, EventDispatchOption.DO_NOT_DISPATCH, false)

Hi @Benz Kek _Adaptavist_ 

Thanks for your reply, I will check if it could match the requirements ;-)

Like Benz Kek _Adaptavist_ likes this

Hello,

We finally ended up by using the native Jira linking, much easier for everyone than kind of reinventing the wheel indeed.

 

Thanks.

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 ? :-)

 

Cheers

Sylvain

Hi Sylvain,

 

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,

 

Regards,

Radek

Hi @Sylvain Leduc 

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

Cheers,
Dan
STAGIL 

Hi @Daniel Fietta 

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.

 

Regards.

Sylvain

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

Regards,
Dan

Suggest an answer

Log in or Sign up to answer
TAGS

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