Forums

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

Inconsistent results with smart value conditionals

Brock Jolet
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.
December 13, 2022

I have a triggerIssue with three linked issues of two different link types. I want only to target a specific link type. I somewhat have this working if I start from an API call, but I get different results if I start from a native smart value.

 

Example:

{{#webhookResponse.body.fields.issuelinks}}{{#if(equals(type.id,"10011"))}}{{inwardIssue.key}},{{/}}{{/}}

This returns a string of "TEST-15,TEST-16", the 2 of 3 links that match "10011".

 

On the other hand...

{{#issue.issuelinks}}{{#if(equals(type.id,"10011"))}}{{inwardIssue.key}},{{/}}{{/}}  

This returns null when I expected the same results.

 

The data I get back from an API call for {{webhookResponse.body.fields.issuelinks}} is a block of text and values. The equivalent {{issue.issuelinks}} returns only the three issue keys.

 

However, these two queries seem to produce the exact same results:

Kid Keys: {{webhookResponse.body.fields.issuelinks.inwardIssue.key}} | Link Types: {{webhookResponse.body.fields.issuelinks.type.id}}
Kid Keys: {{issue.issuelinks.inwardIssue.key}} | Link Types: {{issue.issuelinks.type.id}}

 

I could move forward using an API call, but I was hoping to use native smart values for this rule. Any help with formatting would be appreciated.

3 answers

1 accepted

1 vote
Answer accepted
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.
December 13, 2022

Hi @Brock Jolet 

I reproduced the symptom you are seeing, and...

The webhookResponse is text and the data directly from the issue is not so it has typing information.  For {{issue.issueLinks}}, type.id should be a number for comparison...However with the issue conditional filtering, type.id apparently does not work.  The type.id value is present and it just doesn't pass the conditional.  I recommend submitting a defect to Atlassian for this difference here: https://support.atlassian.com/contact/#/

I have found there are several problems when using conditional filtering and passing issue fields to functions; that is, there is inconsistency in success :^)

 

Now for a work-around: from my tests, type.name can be filtered with a conditional within the iterator.  Please try substituting in the name of your link type to see how that helps.

 

Kind regards,
Bill

Brock Jolet
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.
December 14, 2022

Once again, you've saved the day! Switching to type.name was all I needed to do.

{{#issue.issuelinks}}{{#if(equals(type.name,"Hierarchy [Gantt]"))}}{{inwardIssue.key}},{{/}}{{/}}
Like # people like 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.
December 14, 2022

Awesome; I am glad that helped.

And I still recommend submitting the defect as there is a problem in either/both the REST API method or the rule handling of the results.

Regarding the problems of fields, functions, conditionals inconsistencies...I have submitted several for those "opportunities".

Like Brock Jolet likes this
1 vote
Jose Luis Gonzalez
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 21, 2023

Hi,

 

you should use the .eq(<number>) function for numeric comparisons. Optionally, the .asNumber function to convert from string to numeric values.

Here is the example that worked with the native smart value:

{{#issue.issuelinks}}{{#if(type.id.eq(10001))}}{{type.id}}=>{{inwardIssue.key}}{{/}},{{/}}  

and it worked:

 

Documentation

For numeric comparisons, please use gt(),gte(), eq(), lt(), lte()

The following documentation explains the functions: https://support.atlassian.com/cloud-automation/docs/jira-smart-values-math-expressions/

1 vote
Maksim Marholin
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
December 13, 2022

Hi @Brock Jolet

it seems based on your own investigation, that API call and smart values return data in a different format.

I suspect that is the reason you don't get the expected result.

You probably can build something similar with smart values, but I'm afraid API approach will be cleaner.

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