Forums

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

Comparing a branch issue field value with a list of trigger issue values.

Vitor Prado January 12, 2023

Hi! I'm using Automation and Smart Value in Jira Data center. I'm running an automation in a branch for a related issue of the trigger issue, and I want to go through all the related issues of the trigger issue and comparing a specific field value to a value of another field of the branch issue. So far I'm able to go through to list of the trigger issue related issues, but I can only compare it with a given string, and I don't know if its possible to refer to the branch issue field.

This is what I got working:

{{#triggerIssue.issuelinks.outwardIssue}}
{{equals(customfield_10600, "0010")}}
{{/}}

Instead of using the given string "0010", I wanted to use a value from a field of the branch issue, I know I can refer to it using "issue.customfield_10601", but I can't use it inside the trigger issue list since it would be out of context. Is there any syntax that would work for this case?

Thanks!

1 answer

0 votes
Mark Segall
Community Champion
January 12, 2023

Hi @Vitor Prado - Are you only looking to take action on linked issues where customfield_10600 = 0010?  If so, you could do something like this:

  • BRANCH (Related Issues)
  • CONDITION: JQL
    • Your Custom Field = 0010
  • ACTION: Whatever you're trying to do

If I'm off base, please share a screenshot of your rule so I can better understand what you're trying to accomplish.

Vitor Prado January 17, 2023

Hi @Mark Segall, thanks for the reply and sorry for taking long to get back.

No, customfield_10600 could have different values. What I'm trying to accomplish is, between all the related issues to the trigger issue, I want to compare customfield_10600 and customfield_10601, if they match values, I want to link those issues. I'm doing this so I can set dependencies for further date automation. Since there are over 30 issues on my "template", I thought I could use a custom field to id the issue (say issue "0010") and another custom field to inform which issue it depends on.

What I have so far, is branching each related issue from an automation on the trigger issue (for example, JQL = issue in childIssuesOf("{{triggerIssue.key}}") AND cf[10600] ~ "0020"), and editing it with Smart Values to set the link, as the following example:

{{#triggerIssue.issuelinks.outwardIssue}}
{{#if(equals(customfield_10600, "0010"))}}
{"update": {
"issuelinks": [
{
"add": {
"type": {
"name": "Blocks"
},
"inwardIssue": {
"key": "{{key}}"
}
}
}
]
},
"fields": {
"customfield_10209": "{{customfield_10210}}"
}
}
{{/}}

But I don't want to specify the id (customfield_10601) of the dependent issue on the code, I wanted to call the value from customfield_10601 of the branched issue, with the advantage of changing the custom field value when needed, rather than the smart value code.

Mark Segall
Community Champion
January 17, 2023

Sorry I'm still not quite following what you're trying to do.  Is there anyway you can share a screenshot of the rule so I can see this all in context?  It would really help me wrap my brain around it.  

Also, you said you're on Jira DC.  Am I correct that there is still no option for Lookup Issues as an Automation component?

Like Vitor Prado likes this
Vitor Prado January 17, 2023

Unfortunately Lookup Issues haven't been implemented on Jira DC yet.

I'll try to be clear and upload some screenshots.

From the very beginning, I'm trying to create an issue template with automation, where there'll be a hierarchy with a main parent issue and several child issues (I'm linking them to the parent both using the native parent-link field and relating them so I can go through them with smart values). So the firs part of the automation, which is ok, is having the trigger upon the creation of the parente issue, then creating each of the child issues (they'll have different summaries and other information on specific fields), here is an example:

jira 4.png

The custom field "ID" (customfield_10600) is where I'll set a specific id for the issue, and the custom field "Dependências" (customfield_10601) is where I'll tell which issue ID the issue should be linked to. I chose to refer to the child issues with an ID, since issue keys wouldn't work for this case, and summary is more susceptible to changes.

After creating all the child issues, I need to set the links between specific child issues, that will work kind like dependencies, so I can later set and change dates automatically based on theses links. One option would be filtering each child issue in different branches, and instead of referring to the custom field "DEPENDÊNCIAS", I would just compare the ID of all issues related to the trigger to a given ID, and get that issue's ID to create the link, like this (the additional fields has the same script structure I sent earlier) :

jira 5.png

That's what I have so far, and it works, but I need to repeat it as a branch for each child issue. Rather than doing this, I thought it would be possible to create a single branch for all the related issues (child issues), and then again, with the smart values/json script, going through all the related issues to check the custom field "ID" and see if it matches the custom field "DEPENDÊNCIAS" of the branch issue.

Please, let me know if it's a bit clear now, and thanks for the attention!

Mark Segall
Community Champion
January 17, 2023

Thanks for the added context.  I see what you're trying to do here.  I'm going to tag @Bill Sheboy to see if he's willing/able to help on this one. I need some time to wrap my head around the JSON and that may be a few days before I can have that kind of time to think on it.

Like Vitor Prado 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.
January 17, 2023

Hi @Vitor Prado and @Mark Segall 

If I understand your scenario, you are trying to reference both the trigger issue and branch issue's data within a branch.  That is possible and the smart values referenced is important.  For example:

  • trigger: some trigger...at this point, both {{issue}} and {{triggerIssue}} refer to the same thing
  • action: some action...at this point, both {{issue}} and {{triggerIssue}} refer to the same thing
  • branch: on more that one issue, such as JQL...at this point, both {{issue}} and {{triggerIssue}} refer to the same thing
    • action: another action...at this point, {{issue}} now refers to an issue found by the branch
  • action: one last action...at this point, both {{issue}} and {{triggerIssue}} refer to the same thing

 

I also note you are trying to use dynamically generated JSON inside of a smart value list iterator...inside of a branch!  I have not tried this...and I would expect the following to apply: fields prefixed with issue refer to a branch issue and fields without a prefix refer to the source/iterator smart value list.

branch...

action to edit, with JSON...

{{#triggerIssue.someSmartValueList}}
{{#if(equals(someFieldFromTheList,issue.anotherField))}}
do something...
{{/}}
{{/}}

I would encourage you to grab the contents of your edit field JSON and write it to the audit log before trying the edit.  That will confirm it works as you expect and creates well-formed JSON.

Kind regards,
Bill

Like Mark Segall likes this
Marc Isikoff
Contributor
September 13, 2023

Looking for an example for branching on JQL to limit the scope to a single issue using comparison to trigger issue values.

In my case I have 9 defined stories for an issue type and I want to operate on the one that matches the triggering issue values.

Branch on JQL:

issuetype = 'my custom issue type of 9' and {{issue.fields.customField_12345}} = {{triggerIssue.fields.customField_12345}} 

is not working, possibly because issue = triggerissue and I cannot hone in on the one of 9 that matches the trigger issues custom field 12345 value.

If anyone can help write the branch on JQL for this scenario, I would be very grateful.

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.
September 13, 2023

Hi @Marc Isikoff 

I recommend creating a new question for this one, and perhaps linking back to this thread.  Otherwise only people following this older thread will see it to suggest ideas.

And when you create that question, I recommend posting images of your complete rule, including details of the branch, and of the audit log details showing the rule execution.  Those will provide context for the community to help.  Thanks!

Kind regards,
Bill

Marc Isikoff
Contributor
September 13, 2023

Thanks Bill but figured it out (cannot paste images b/c of employer).

In JQL Branching check, if you want to limit the issues down to one to work on by comparing it to trigger issue's values you have to just put your custom fields in quotes, e.g., "time period" ~ {{triggerissue.field.customfield_12345}} 

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.
September 13, 2023

Yup: for JQL and smart values, often the challenge is learning the correct name/format to use for a field.

Suggest an answer

Log in or Sign up to answer