Forums

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

How to return string from a smart value IF function

Peter Chodakowski
Contributor
April 6, 2021 edited

Hello-

I have an automation that creates a new issue when a webhook is triggered (the source of the webhook is another Jira instance).

I want to populate data only if it actually exists. For example, if the "location" custom field has a value, add that to the description.  If not, add "not selected".

This is what I have in the description field:


{{#=}}IF({{webhookData.fields.customfield_11356.value.isNotEmpty()}},"{{webhookData.fields.customfield_11356.value}}",0){{/}}

Note that this works fine if I only want to return a number, but as soon as I have the value returned if true set to some sort of string, I get an error stating "Unable to parse expression IF(true,"Bettendorf",0): IF(true,"Bettendorf",0)"

I've tried adding double quotes, no quotes, escaped quotes. I can't seem to get this to work.

 

Any ideas?

1 answer

0 votes
Nir Haimov
Community Champion
April 7, 2021

Hi @Peter Chodakowski 

Can you recreate your automation here:

https://www.atlassian.com/software/jira/automation-template-library/rules#/labels/all/customLabelId/1453

?

And share the link to your rule, it will be easier to see what you did and try to help

Peter Chodakowski
Contributor
April 7, 2021

I've tried to add it a few times but keep getting an error.

 

Here's what I'm trying to do.  The field "customfield_11356" may or may not contain a value. I want to test to see if it has a value, and if so, to put that value in the description. If not, put "not selected".

In other words:
IF(field is not empty, <value of the field>, "not selected")

 

This DOES work if the <value if true> and <value if false> parameters are numbers. It does not seem to work with text.

Attached a screenshot in case that helps.

Screen Shot 2021-04-07 at 09.56.30.png

Mark Chaimungkalanont
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 3, 2021

Hey there Peter,

Sorry a bit late in here but the format for this would be:

{{if(webhookData.fields.customfield_11356.value.isNotEmpty(), webhookData.fields.customfield_11356.value, "None selected")}}

You might need to play around with webhookData.fields.customfield_11356.value.isNotEmpty() for it to return true / false as you expect, but that should work. 

 

Cheers,

Mark C

Suggest an answer

Log in or Sign up to answer
TAGS
atlassian, loom, loom for training, loom for teaching, video training, async learning, online education, screen recording, loom tutorials, loom use cases, atlassian learning, team training tools, instructional video, virtual training tools

🛗 Elevate Your Training and Enablement with Loom

Join us June 26, 11am PT for a webinar with Atlassian Champion Robert Hean & Loom’s Brittany Soinski. Hear tips, stories, and get your burning questions answered. Learn how Loom makes training and enablement easier. Don’t miss it!

Register today
AUG Leaders

Atlassian Community Events