Smart value for linked "relates to" inwardIssue in Jira Automation rule

Sam Adams April 26, 2023

Hi, Trying to make a simple Jira Automation (conditional) rule that (if met) adds a label that contains a smart value of the inward related issue
Example

  • Jira Story A
    • "relates to" linked Jira Story B
  • Action Code I have to add label with the condition met
    • {
      "update": {
      "labels": [{
      "add": "tmsLink={{issue.issuelinks.inwardIssue.key}}"
      }]
      }
      }

So this rule works as is if I only have one linked story (like above). But if I have multiple linked issues with different link types ("is cloned by" or "is blocked by" etc.) it fails to grab the issue id key. Is there a way I can specify in the json that I only want it to lookup/grab the related issue key that is "relates to"?   

2 answers

1 accepted

3 votes
Answer accepted
Trudy Claspill
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 26, 2023

What is the trigger for your rule?

Can you show us the entire rule?

Sam Adams April 26, 2023

-

Sam Adams April 26, 2023

Thanks @Trudy Claspill , included a screen shot. Trigger is "Issue Updated". Again, the trigger and or condition of the rule doesn't seem to be the issue.....and when I have an issue that has only one related linked issue this rule works fine. It's when I have multiple linked issues with different link types ("is cloned by" or "is blocked by" etc.) with in an issue that this rule fails

2023-04-26_15-06-12.png

Trudy Claspill
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 26, 2023

Hi Sam,

There is no screen image.

I asked about the trigger because if you were using the Issue Linked trigger that would give you access to both issues in the link pair.

I'll await your screen image before offering other guidance that might not be useful. :)

<edited>

There's the screen image!

Sam Adams April 26, 2023

Odd...thought it showed up. Here is an image now @Trudy Claspill . Thanks

2023-04-26_15-06-12.png

Trudy Claspill
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 26, 2023

I have to dash, but I thought I'd throw this out.

You could use a Lookup Issues action to retrieve the issues that have the "relates to" link to your trigger issue. Then you can get the key(s) for those issues from the Lookup Issue results which is a list.

i.e.

Lookup Issues action JQL

issue in linkedIssues({{triggerIssue.key}},"relates to)

Then

{{lookupIssues.first.key}}

would give you the issue key for the first issue returned in the Lookup Issues results list.

Like # people like this
Sam Adams April 26, 2023

Oh man....im close on this. Sorry...one last question @Trudy Claspill . So I tried your suggestion (switching to the linked trigger) See image below. It works as far as the logic is concerned. But it applied adding the new label to the issue that was linked vs the issue I was in. I need the label to be added to the issue im in that I did the link in (not the linked issue that triggered it). Any way to get around that with this trigger? Or will it always apply the add to the issue that triggered it?2023-04-26_16-49-19.png

Trudy Claspill
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 27, 2023

When using the Issue Linked trigger you have to be aware of which issue in the pair is considered the "source" and which is considered the "destination" when the link is created. This is usually distinguished by the Inward and Outward Descriptions used by that link type and how those apply to the pair of issues.

Screen Shot 2023-04-27 at 11.53.35 AM.png

With the "relates to" link the Inward and Outward Descriptions are the same, you you can't tell based on that.

I experimented with a rule that was triggered by the Relates To link being created and found that that the issue from which the link is created is considered the "destination", and the issue being linked to is the "source". So it is the issue that you are linking to that is the trigger issue.

If you need to apply a condition or update to the issue you created that link from, then within the rule you need to add steps to change your context to that issue.

To do that I would recommend that you use a For Branch / Related Issues / JQL step

Screen Shot 2023-04-27 at 12.01.37 PM.png

Then anything you want to do against the issue from which you created the link would be an action within the branch.

Screen Shot 2023-04-27 at 12.06.59 PM.png

Like Gábor Budai likes this
Sam Adams April 27, 2023

Thanks so much @Trudy Claspill for the example and screen shots. It helped a ton.....and I'm happy to report this worked!! I had to slightly change the json on my Then portion of the rule but after that it worked like a champ. Thanks so much...saved me a bunch of time and taught me a lot2023-04-27_14-38-58.png

Like Trudy Claspill likes this
0 votes
Bill Sheboy
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.
April 26, 2023

Hi @Sam Adams 

When you have multiple labels you want to add (for the linked issues), you will need an "add" clause for each one in the JSON.  This can be done by iterating over the issue links in the list to build a JSON expression for each.  Please try that approach and let me know if need more details.

Kind regards,
Bill

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
TAGS
AUG Leaders

Atlassian Community Events