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

Getting the parent issue key in automation

Jamshaid
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 12, 2024

I have two projects TM and CO. When in TM, an issue is created, same issue is cloned to CO and a Cloners link is created between both issues.

What I want to do is that when the issue in CO is transitioned to Done, it should send a web request having the key of parent issue in TM project in its parameters or body. I am unable to get the link between both issues. Here is what I have tried

 123.png

  But, this condition never triggered. It always ends up with this response

1234.png

I am unable to get what I should do regarding this as I am totally new to automation in Jira.

Thanks

 

3 answers

1 accepted

0 votes
Answer accepted
Jamshaid
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, 2024

I had to transition the linked issue to Done state and send a web request containing the parent issue key. Here is how I did it. I created a shared rule between both projects and then used the following automation flow to close the issue and send web request.

 

Screenshot from 2024-02-26 21-34-45.png

0 votes
Kalyan Sattaluri
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 13, 2024

@Jamshaid  Is your TM project available in scope from the rule of CO project?

I just tested a similar set up and if the cloned issue is within the same project, branch logic like you have picks it up as expected but if you dont have "scope" then you wont get the key from TM project.

So if thats the case with you and that is why you are not able to get the key, I was thinking of below approach which is without the branch logic.

But please confirm above step as thats the easiest route or work with your admin if you can be granted that scope.


My proposal was, Before your branch, first please try to log below smart value, should pull the list of keys.. modify the if condition accordingly.
 
{{#issue.issuelinks}}{{#if(equals(type.name,"Cloners"))}}{{inwardIssue.key}}{{^last}}, {{/}}{{/}}{{/}}
 
You then convert this into a list by first storing above smart value into a variable (myvar) and doing a split. {{myvar.split(", ")}}, now you have a list of keys.
 
If you want to loop through and make a web request call for each of "parent" /original cloned link, I believe you can do an "advanced branch" afterwards on  {{myvar.split(", ")}} and make your web request calls for each "key" that way. Something along the lines of below thread or similar posts which loop over a list.
 
  
hope it helps. If this is not what you are thinking of, please help explain what do you want to do.

image.png

Jamshaid
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 13, 2024

@Kalyan Sattaluri Thanks. I am not really concerned about using branch logic. I just want to get the key of the parent issue. It is supposed to be only one having the current logic. 
I will try your solution. 

 

 

Kalyan Sattaluri
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 13, 2024

@Jamshaid  Sure, Just edited my post with screenshot, please check and let me know

Jamshaid
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 13, 2024

@Kalyan Sattaluri I can't find Add value to Audit Log in then: Add an action 

 

Kalyan Sattaluri
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 13, 2024

In cloud, its called "Log action", please verify.

 

BTW, if you know you will only have 1 ofsuch cloned issue, you can skip variable part.

Either way, please log value first to check you are getting the value.

image.png

Jamshaid
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 13, 2024

@Kalyan Sattaluri 

Here is what appears in logs. It does not print anything from issue

logs.png

 

Here is my rule

111.png

Here is the issue CO18

co18.png

 

 

Kalyan Sattaluri
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 13, 2024

Your log below has TM-63 and your screenshot has TM-67.

Please post similar log like you posted below so we can cross check that it should be "inwards" or outwards direction in our log action

 

Jamshaid
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 13, 2024

@Kalyan Sattaluri I have got the list of linked issues. Thanks for your help

{{issue.links}}  worked for me. It is enough for now.

Jamshaid
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 13, 2024

@Kalyan Sattaluri The json shows that it is an inward 

 "issuelinks": [
{
"id": "10656",
"self": "https://mysite.atlassian.net/rest/api/2/issueLink/10656",
"type": {
"id": "10001",
"name": "Cloners",
"inward": "is cloned by",
"outward": "clones",
"self": "https://mysite.atlassian.net/rest/api/2/issueLinkType/10001"
},
"inwardIssue": {
"id": "11214",
"key": "TM-63",
"self": "https://mysite.atlassian.net/rest/api/2/issue/11214",
"fields": {
"summary": "test211",
"status": {
"self": "https://mysite.atlassian.net/rest/api/2/status/10001",
"description": "",
"iconUrl": "https://mysite.atlassian.net/images/icons/status_generic.gif",
"name": "Done",
"id": "10001",
"statusCategory": {
"self": "https://mysite.atlassian.net/rest/api/2/statuscategory/3",
"id": 3,
"key": "done",
"colorName": "green",
"name": "Done"
}.  

I don't know why the condition you shared is not working 

Kalyan Sattaluri
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 13, 2024

Great, but the JSON you are showing again is for TM-63 and your screenshot has TM-67. I am curious whats the difference in link types between the two because syntax worked for me. Thats why I asked for JSON which showed TM-67 to look at the difference.

Either way, looks like you got what you wanted. Problem solved!

Jamshaid
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 13, 2024

@Kalyan Sattaluri that json was for another issue. I just copied it from my other comments in this post.

I have linked another issue and it shows a comma (,) only in logs while trying your condition. Maybe something got changed by the webpage when you pasted the condition?

Jamshaid
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 13, 2024

@Kalyan Sattaluri The condition works with outwardIssue.key

{{#issue.issuelinks}}{{#if(equals(type.name,"Cloners"))}}{{outwardIssue.key}}{{^last}}, {{/}}{{/}}{{/}}

 

 

Kalyan Sattaluri
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 15, 2024

@Jamshaid  if you have figured out a way, please consider to put it in a new post and mark your answer as accepted so others can benefit and that way this issue is closed.

0 votes
Rudy Holtkamp
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 12, 2024

Hi @Jamshaid ,

Maybe you should use 'cloned by' instead of 'clones' in the branch.

It depends how the two issues are linked.

Jamshaid
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 13, 2024

@Rudy Holtkamp Even if i use is cloned by, it throws the same message in logs

 

Rudy Holtkamp
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 13, 2024

The log says that it can't find a linked issue of the link type 'clones'.

So you might want to take a closer look to the issue by using:

https://yoursite.atlassian.net/rest/api/latest/issue/CO-17?expand=names

Then search for 'issuelinks', you should see something like this:

"issuelinks"[
{
"id": "10762",
"self": "https://rudy.atlassian.net/rest/api/2/issueLink/10762",
"type": {
"id": "10001",
"name": "Cloners",
"inward": "is cloned by",
"outward": "clones",
"self": "https://rudy.atlassian.net/rest/api/2/issueLinkType/10001"
},
"outwardIssue": {
"id": "11999",
"key": "RUDY-15",
"self": "https://rudy.atlassian.net/rest/api/2/issue/11999",
"fields": {}
}
}
]

Note: I use Chrome with an extension called JSON formatter.

Jamshaid
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 13, 2024

@Rudy Holtkamp this is the relevant output

 "issuelinks": [
{
"id": "10656",
"self": "https://mysite.atlassian.net/rest/api/2/issueLink/10656",
"type": {
"id": "10001",
"name": "Cloners",
"inward": "is cloned by",
"outward": "clones",
"self": "https://mysite.atlassian.net/rest/api/2/issueLinkType/10001"
},
"inwardIssue": {
"id": "11214",
"key": "TM-63",
"self": "https://mysite.atlassian.net/rest/api/2/issue/11214",
"fields": {
"summary": "test211",
"status": {
"self": "https://mysite.atlassian.net/rest/api/2/status/10001",
"description": "",
"iconUrl": "https://mysite.atlassian.net/images/icons/status_generic.gif",
"name": "Done",
"id": "10001",
"statusCategory": {
"self": "https://mysite.atlassian.net/rest/api/2/statuscategory/3",
"id": 3,
"key": "done",
"colorName": "green",
"name": "Done"
}
},
"priority": {
"self": "https://mysite.atlassian.net/rest/api/2/priority/3",
"iconUrl": "https://luminsec.atlassian.net/images/icons/priorities/medium.svg",
"name": "Medium",
"id": "3"
},
"issuetype": {
"self": "https://mysite.atlassian.net/rest/api/2/issuetype/10101",
"id": "10101",
"description": "A problem which impairs or prevents the functions of the product.",
"iconUrl": "https://mysite.atlassian.net/rest/api/2/universal_avatar/view/type/issuetype/avatar/10303?size=medium",
"name": "Bug",
"subtask": false,
"avatarId": 10303,
"hierarchyLevel": 0
}
}
}
}
],

 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events