Triggering link creation.

Denis Burdukovskiy July 3, 2017

Hello, is it possible (or planned) to do something on a link creation ?

For example: When I add a specific link type to an issue ("is caused by" supposed), then something happens/

1 answer

0 votes
andreas
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.
July 3, 2017

Hi Denis,

This is a bit tricky since JIRA doesn't provide an 'Issue Linked' event that we can listen to (see https://jira.atlassian.com/browse/JRASERVER-8505).

The same problem exists in Cloud.  I think there were some webhooks added recently, but AFAIK they are not exposed yet through the atlassian connect add-on framework.

Cheers,
  Andreas

Denis Burdukovskiy July 4, 2017

Understood. I found some workaround, but need help.

The main task to be acheived: Suppose, there's issue EX-1. And in EX-2 a create a link "is caused by" to EX-1. After that I'd like that some fields from EX-1 to be copied automatically to EX-2.

If we can't get event on linking, I can use other triggers (transition, update). But I can't find out how to copy values. Probably some construction has to be made in Advanced section (Edit Issue action)? Is it possible to make the task with the Add-on ?

andreas
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.
July 4, 2017

Hi Denis,

it depends a bit on what type of field you're trying to copy (text, select, user select etc).

However you can use smart-values with the edit issue action to copy fields (see https://codebarrel.atlassian.net/wiki/display/AUTO4J/Smart+Fields for more details).

Bascially you'd add the target field to the edit-issue form (say it's a text field called 'Operating System' and then you'd fill this field with:

{{triggerIssue.fields.Operating System}}

This would substitute the value from the trigger issue into this field.  

For select fields you need to append '.value' at the end.  You can also print smart values using the 'Log action' in the audit log.

We're going to make field copying easier in future but for now you'll have to use smart values.

Cheers,
   Andreas

Denis Burdukovskiy July 5, 2017

Andreas, thanks for help and attention.

Sorry, but I still can't get it, how to reffer to a link issue field :( . Could you give an example how to copy, let's say, Components field from EX-2 to EX-1. Assuming, that EX-1 is caused by EX-2 ?

Denis Burdukovskiy July 5, 2017

I found how to filter linked Issues of certaint type by JQL

issue in linkedIssues({{issue.key}},"is caused by") 

and how reffer to them. But I need to do vice verser : make changes to trigger Issue from filtered (branched) issue.

In other words, can I make changes from selected section to triggerIssue (Issue itransitioned) ?

Capture.JPG

andreas
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.
July 5, 2017

Hi Denis,

No this isn't possible yet and it's a bit tricky to implement.  That JQL could match multiple issues, which means if the 'Edit issue' action would edit the trigger issue, then there could be multiple edits where each overwrites the previous edit.  This woudl be quite confusing.

I think perhaps what we might need is some kind of support fetching a related issue field's value in smart-values but that's tricky.

Off the top of my head you'd need something like this in smat-values I guess (*NOTE* this is just an idea and wont work right now)

{{issue.related("linked").matches("type = bug").first.fields.description}}

Then you could simply have the rule like:

  • Trigger: transitioned
  • Edit issue: (with smart-value above)

We'll have to think this through a bit - the syntax above isn't intuitive at all - we'd probably have to include some sort of UI builder for this.  I've raised https://codebarrel.atlassian.net/browse/AUT-425 for now.

Cheers,
  Andreas

Denis Burdukovskiy July 6, 2017

That JQL could match multiple issues, which means if the 'Edit issue' action would edit the trigger issue, then there could be multiple edits where each overwrites the previous edit.

I thought about it.

That would be great to operate with first, last values. For example, issue.related ("linked").last.fields....

But, as far as I could find out, the IssueLinks array in JSON is sorted in strange way and the last issue linked is not actualy last/first element of array.

p.s. still many thanks for response !

Suggest an answer

Log in or Sign up to answer