Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Jira Automation - link new issues on different parts of a rule

Ivan Donigevich February 24, 2021

Hello,

I have a working part of a rule where:

1. an issue is created

2. the branch "For the most recent created issue" creates another issue and links it to the one above.

I need to link an issue created in this branch to another issue too.

I tried the same approach when another issue is followed by the branch "For the most recent created issue" but didn't find a way to pass there issue key of an issue created before.

Using JQL looking for an issue with some custom field value doesn't pass it.

Appreciate any idea.

 

BR,

Ivan

3 answers

2 accepted

1 vote
Answer accepted
adrien miniere March 21, 2024

Hi, I had a similar issue and helped myself at this contribution. I solved it the following way:

rule1.PNG

in the "create a new issue" action, I set the following values for the json object:

rule1-json.PNG

and it worked pretty well. In my case, the ITSAMPLE service project is a second project, external to the one, where the rule is executed, but on the same tenant. The issueKey smart value simply takes the value: "  {{issue.key}}  ". It retrieves the key of the subtask just created in the automation, so not the key value from the parent issue, which triggered the automation, but the key value of the last created subtask.

Regards

Adrien

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.
March 21, 2024

Hi @adrien miniere 

Thanks for that information; it is interesting that it works now.

The REST API for the issue create supports adding one link at the time of issue create, but that did not work in automation rules just a few months ago.  Instead rules needed two actions: create issue and then add the link.  Looks like Atlassian fixed something :^)

Kind regards,
Bill

1 vote
Answer accepted
Kian Stack Mumo Systems
Community Champion
February 24, 2021

@Ivan Donigevich

I'm not quite following exactly what you are trying to do, but I'd take a look at using the Create variable action.

 

You can use this to store a value which you can access later. So after creating an issue, perform the action

 

Screen Shot 2021-02-24 at 12.58.49 PM.png

 

You can then later access this variable using {{recentissuekey}}.

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.
February 24, 2021

Hi @Ivan Donigevich 

Yes, and... to the suggestion from @Kian Stack Mumo Systems 

Create Variable has some limits for scoping, so if you create a variable inside of the branch it may not have a value elsewhere in the rule.  As a work-around you may want to create the variable and assign it to {{createdIssue.key}} before you branch.

Please see this article for some "spirited conversation" on this topic:

https://community.atlassian.com/t5/Jira-articles/Automation-for-Jira-Create-variable-New-component/ba-p/1448118

Best regards,

Bill

Ivan Donigevich February 24, 2021

Kian, Bill,

 

Thank you for the prompt response.

I guess using the variable value should be for the 2nd linked issue via Editing Issue action in its Additional fields section where I can assign an issue key and a link type to sub fields of Linked Issue field in JSON.

Can you please suggest how these sub fields are named and the assignment would look like? Here I haven't found them.

 

BR,

Ivan

Kian Stack Mumo Systems
Community Champion
February 24, 2021

@Ivan Donigevich

I'm not quite sure that I'm understanding what you are asking. Perhaps a screenshot of the rule would be helpful.

0 votes
Ivan Donigevich February 24, 2021

Moved to reply section

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.
February 24, 2021

Ivan, would you please post an image of your rule?  That may provide some context for the community to help you on this next question?  Thanks!

__Bill

Ivan Donigevich February 24, 2021

Bill,

 

The actions are that.

The long arrow shows extension of the rule, the blue one - what issues are to be linked, the short arrow - where I'm going to edit the most recent issue and what issue key with.

So here:

1. Story and 2 Tasks are created, then the Tasks are linked to the Story (the left part of rule)

2. The right part: Task is created and it is to be linked to the 2nd Task.

 

BR,

Ivan

 

Linking issues.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.
February 24, 2021

Thanks for that image of the rule.

Just to check, is this working as you expect?  Branches run asychronously and so do not necessarily complete before the following steps, leading to timing issues in rule execution.  The 3rd task you are creating is *outside* of the branch, and so it is unclear what the value of "most recently created issue" will be:

  • it could be nothing (no tasks created yet), or
  • it could be the first task created, or
  • it could be the second task created.

If all of the creates are within the branch (or outside of a branch) you can probably expect the steps occurring sequentially.

Ivan Donigevich February 25, 2021

Yes, it's working correctly, the issues are created and linked in the order they are in the main rule and its branches. I believe as the branches are on different levels of the main rule trunk, a fork point stops going down the trunk till a branch is finished. Eventually it just expected to be so!)

Unfortunately branches cannot be nested else I would resolve this case easily. So now I need to know how to put a value in sub fields of linkedIssue field. Probably it can be done in Additional fields section of the Edit Issue fields action.

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.
February 25, 2021

Ivan, I am glad to hear it appears to be working, and...

Just to confirm what I was describing: the way the rule appears in the editor does not guarantee execution order when there are branches.  Once you reach the point of a branch, anything inside of the branch gets queued to execute independently.  The documentation states that branches with only one issue stay in-line (sequential), however some recent posts in the community indicate this is not the case.  So, buyer beware for timing issues.  ;^)

Best regards,

Bill

Ivan Donigevich February 25, 2021

Bill,

Thank you for the support.

Even if branches work simultaneously I believe each works on the most recently created issue related exactly to it and not on some created later for another branch or so.

Anyway I would test passing createdIssue.key to another issue's linked issue field as I can't see another way to link 2 issues created in different parts of a rule.

So the current question is how to assign values to the Linked Issue sub fields in JSON.

BR,

Ivan

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.
February 25, 2021

Ivan, what values do you want to assign and to which fields?

Ivan Donigevich February 26, 2021

Bill,

 

I'm going to get an issue key of one of tickets to be linked in some variable as it's suggested by Kian and to assign it to the Issue sub field of another ticket's Links field. Also I want to assign a link type to the Linked Issues sub field.

So I expect to get in JSON section of Edit Issue action something like that:

"fields": {
    "Links": {
           "Issue": <Variable with {{createdIssue.key}}>
            "Linked Issues": "blocks"
     }
}

But I don't know how the Links field and its sub fields can be applied - here they aren't available in the list. Does it mean - no way?

 

BR,

Ivan

 Linked Issue.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.
February 26, 2021

To add links with types using JSON, please look at his documentation:

https://support.atlassian.com/jira-software-cloud/docs/advanced-field-editing-json/

But if you are instead trying to "walk the tree" downward, updating issues in linked issues from the JSON, I do not believe that can work.  A specific issue must in scope (e.g. within a branch, or triggerIssue) for the JSON to work.

Ivan Donigevich February 27, 2021

Bill,

 

Thanks a lot for the link - it's what I've been looking for.

I will play with Linking issues JSON - hope it will help. Anyway I don't see another way to pass parameters of one issue to another.

 

BR,

Ivan

Suggest an answer

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

Atlassian Community Events