How to compare to smart values like a ternary operator

brady_leach March 28, 2023

I have an automation that clones an issue. The trigger issue has a custom field that will be used to name the cloned issue. If this field is empty, I would like to use the trigger issue summary to name the cloned issue. For example

image.png

2 answers

1 accepted

0 votes
Answer accepted
brady_leach March 29, 2023

I had to use the advanced smart value features and a bit of trial and error for the correct conditions to get it to work. For some reason, isEmpty doesn't seem to work as I expected on my version of Jira Cloud. 

 

In the end, the final value looked like:

{{#if(exists(triggerIssue.My Custom Field))}}{{triggerIssue.My Custom Field}}{{/}}
{{#if(not(exists(triggerIssue.My Custom Field)))}}{{triggerIssue.summary}}{{/}}

0 votes
Alex Koxaras _Relational_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 29, 2023

Hi @brady_leach and welcome to the community,

You can use the conditional logic of smart values https://support.atlassian.com/cloud-automation/docs/jira-smart-values-conditional-logic/

But since the ternary operator is not supported, I would use two IF statements.

brady_leach March 29, 2023

Hi, Thanks for the feedback.

Is it possible to do this comparison from within the create variable action? If so, could you provide an example?

The part I am struggling with is when I need to work with 2 smart values. 

What I am trying to do is in pseudocode

IF 
{{triggerIssue.My Custom Field}} IS NOT EMPTY
smartValue = {{triggerIssue.My Custom Field}}
ELSE
smartValue = {{triggerIssue.summary}}
Alex Koxaras _Relational_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 29, 2023

@brady_leach inside the variable type the following:

{{#if(not(issue.My Custom Field.isEmpty))}}{{issue.My Custom Field}}{{/}}{{#if(issue.My Custom Field.isEmpty)}}{{issue.Summary}}{{/}}

Make any replacements necessary. On my instance it works fine! 

brady_leach March 29, 2023

@Alex Koxaras _Relational_ Thank you. Can I confirm that if the `My Custom Field` value is empty, it will use the `summary` value? My system will default empty string if the `My Custom Field` isn't set.

brady_leach March 29, 2023

@Alex Koxaras _Relational_ I got it working; thanks for your guidance. There seems to be an issue with the isEmpty on the short text field. In order to get it to work, I had to do 

{{#if(exists(triggerIssue.My Custom Field))}}{{triggerIssue.My Custom Field}}{{/}}{{#if(not(exists(triggerIssue.My Custom Field)))}}{{triggerIssue.summary}}{{/}}

 

Thanks again! 

Suggest an answer

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

Atlassian Community Events