Forums

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

Conditionally concatenating JSM Form smart values

Bryan Guffey
Community Champion
May 20, 2025

I'm trying to concatenate JSM form values to create an address but ONLY if they have a value in them. The smart values for the form fields are as follows

  • {{issue.forms.1f28bc04-0d32-402a-8b0e-d34cce50096c.in-emp-subloc-3}}

  • {{issue.forms.1f28bc04-0d32-402a-8b0e-d34cce50096c.in-emp-subloc-2}}
  • {{issue.forms.1f28bc04-0d32-402a-8b0e-d34cce50096c.in-emp-subloc}}
  • {{issue.forms.1f28bc04-0d32-402a-8b0e-d34cce50096c.iin-emp-locality}}

I'm currently using the following smart value with concat() and if() functions:

{{concat(issue.forms.1f28bc04-0d32-402a-8b0e-d34cce50096c.in-emp-subloc-3, if(issue.forms.1f28bc04-0d32-402a-8b0e-d34cce50096c.in-emp-subloc-3, ", "), issue.forms.1f28bc04-0d32-402a-8b0e-d34cce50096c.in-emp-subloc-2, if(issue.forms.1f28bc04-0d32-402a-8b0e-d34cce50096c.in-emp-subloc-2, ", "), issue.forms.1f28bc04-0d32-402a-8b0e-d34cce50096c.in-emp-subloc, if(issue.forms.1f28bc04-0d32-402a-8b0e-d34cce50096c.in-emp-subloc, ", "), issue.forms.1f28bc04-0d32-402a-8b0e-d34cce50096c.iin-emp-locality)}}

The form fields are as follows: 

  • in-emp-subloc-3 - Sub-locality 3
  • in-emp-subloc-2 - Sub-locality 2
  • in-emp-subloc - Sub-locality
  • in-emp-locality - Locality

So, for example, given the following set of values:

  • Sub-locality 3: Box 34, Unit 5
  • Sub-locality 2: Yerendra Square
  • Sub-locality: Western Arm
  • Locality: Yarani

The output would be: Box 34, Unit 5, Yerendra Square, Western Arm, Yarani

But given the following set of values:

  • Sub-locality 2: Yerendra Square
  • Sub-locality: Western Arm
  • Locality: Yarani

The output would be: "Yerendra Square, Western Arm, Yarani"not ", Yerendra Square, Western Arm, Yarani"

However, when I try to return the smart value above, I just get an empty string. 

Any ideas? 

 

2 answers

2 votes
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.
May 21, 2025

Hi @Bryan Guffey 

First thing: detecting empty (or blank) fields is not always simple in rules.  Their field types, context, and whether or not they had a value which was cleared make things challenging.  And...

Rules do not support nesting conditions within the concat() function.  Please try using individual conditional expressions, side by side, storing the result in a created variable.  Then use text functions to remove any stray values.

 

Or easier still, place all of the values side-by-side with comma-delimiters, storing in a variable.  Then split() the values and use match() to remove any empty values.  You may need to adjust this if any of your field values could contain commas (such as by changing the delimiter to a tilde ~).

For example, with some fake form field names:

  • action: create variable
    • name: varFieldList
    • value: {{formFieldA}}, {{formFieldB}}, {{formFieldC}}, {{formFieldD}}
  • action: something that needs the cleaned-up list...
    • {{varFieldList.split(", ").match("(.++)").join(", ")}}

 

Kind regards,
Bill

0 votes
Harrison Ponce May 21, 2025

Hi there, @Bryan Guffey , great use-case! Can I ask if this is through automation, and if so, are you outputting to a larger paragraph field (e.g., description) or some other shorter custom field?

Suggest an answer

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

Atlassian Community Events