Retrieving created issue Key to update the Trigger Issue

José Ramón Sagarna October 31, 2023

Hi,

I'm trying to retrieve the key from a created issue to fill a custom field in the trigger issue.

Trigger and Created issues are in different projects and are sub task types

 

Problem is that I need to branch it to retrieve data from the Created parent issue to gather the key of a previously created issue that will be the parent of the new one in a different project)

JIRA.png

 

Trying so many ways API seems the direction but I get a 405 whenever i try to use smart values in the URL.

 

Any clues?

Thanks in advance

1 answer

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.
October 31, 2023

Hi @José Ramón Sagarna 

If you write that constructed URL to the audit log, what do you see?

And, have you confirmed your request is set up correctly.  Please see this article for an example: https://community.atlassian.com/t5/Jira-articles/Automation-for-Jira-Send-web-request-using-Jira-REST-API/ba-p/1443828

Kind regards,
Bill

José Ramón Sagarna October 31, 2023

Hey Bill, thanks for answering


Got a 405 error:

Error publishing web request. Response HTTP status:
405
Error response HTTP body:

If I change {{issue.parent.key.urlEncode}} to for example ABC-1 it works

And yes, i saw that one and i followed it

Like Bill Sheboy likes this
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.
October 31, 2023

Understood, but if you write that dynamic URL expression to the audit log, run your rule, and post the audit log details, it may reveal this is not formatting as expected.

My guess is this is caused by one of two possibilities:

  1. There is a known issue with the Issue Created trigger that it can fire so quickly that the issue data is not present at the time the rule runs.  The impact is missing data could cause actions / conditions / branches to not behave as expected.  The work-around for that is to always add a Re-fetch Issue action immediately after that trigger type, which will slow down the rule by about a second and reload the data before proceeding.
  2. For some other reason, your fields / smart values are null, leading to an invalid URL for the call
Like José Ramón Sagarna likes this
José Ramón Sagarna October 31, 2023

i see, couple of questions to confirm,

  • I should be able to get the data from the trigger issue even if i am in a branch, right?
  • If that's so, i've see two ways {{issue.parent.key}} and {{TriggerIssue.key}}, do you know if there any others?
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.
October 31, 2023

First thing, have you tried adding the Re-fetch Issue action to solve this?

On to your questions...

Yes, the {{triggerIssue}} smart value is available anywhere in the rule.  (It is even available if there is no trigger issue!)

For your second question, please note that context is important for rules:

  • {{triggerIssue}} always refers to the trigger issue
  • But {{issue}} refers to whatever the "current issue" is at a point in the rule.
    • Outside of a branch, {{issue}} is the same as {{triggerIssue}}
    • Inside of a branch, {{issue}} refers to the currently branched-to issue

I am unclear which issue you are trying to access with the Send Web Request action.  If you describe that it may clarify which smart value to use.

Like José Ramón Sagarna likes this
José Ramón Sagarna October 31, 2023

Yep, I'm trying to use the re-fetch , seem that it's going that way but also i am not pointing to the right one.

Parent issue ID: '616621' / Key: 'ITCR-68' can not be sub-task. (issuetype)

It seems it's taking the Trigger as the one created in the branch, and what I need is the
very first one in the image flow above

Thanks for the help!

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.
October 31, 2023

If you want to update the trigger issue, I recommend changing the rule as follows:

  • trigger: issue created
  • action: re-fetch issue
  • action: lookup issues with JQL to load the issue you were instead branching to
  • advanced compare condition: Check if there was an issue found before proceeding.
    • first value: {{lookupIssues.size|0}}
    • condition: equals
    • second value: 1
  • action: create issue, using data from {{lookupIssues}} and {{triggerIssue}} as needed
  • action: edit issue (This will update the trigger issue, because we are no longer using a branch.)

What do you think?

Like José Ramón Sagarna likes this
José Ramón Sagarna November 2, 2023

Hey Bill, thanks for the answer,

it looked good but i've still got the same error following that flow

Create issue
Error creating issue
Parent issue ID: '620343' / Key: 'RCPM-506' can not be sub-task. (issuetype)

 

I think that if Branched is not used, it will try to create the subtask in the trigger issue not in the lookup one

 

JIRA.png

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.
November 2, 2023

Rather than selecting Current Issue for the parent field, please type in the smart value for the key you want to use.

When you do that, the key will appear below the field, and then it may be selected for use in the action.

José Ramón Sagarna November 2, 2023

it seem that this drop down only allows to choose between current and trigger issue, no input for variables.

Neither the current or the trigger will be the parent in this case

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.
November 2, 2023

The UI for the rule edit is not clear on this feature...

  • Rather than select the drop-down, type in the smart value
  • The value will appear below the field
  • When it does, select it with your mouse cursor
  • The smart value will then be used to set the field value.
José Ramón Sagarna November 3, 2023

Hi Bill,

I was referring to the create, not to the edit . In the create one only two options are available and no way to input anything.


In any case, I've took a different route and automate it via API as it seems that it's not doable using the pre defined actions.

 

Thanks for your help!

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.
November 3, 2023

I am glad you found a work-around, and...

 

Are you using Jira Cloud?

If so, I just checked again and a smart value can be typed in for linking issues, both for the Create Issue and the Edit Issue actions.  Earlier I noted the steps how to do that.

If instead you are using Jira Server, I do not know if that method works.

Suggest an answer

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

Atlassian Community Events