In my automation I'm calling the Atlassian API and want to populate a variable based on the following condition:
{{if(or(webResponse.body.id.contains("customfield_1"),webResponse.body.id.contains("customfield_2")),"fieldsPresent","fieldsNotPresent")}}
Hi @Jared SchmittYes, the "contains" is not supported. Instead, you can try to use match(){{if(or(webResponse.body.id.match("customfield_1"),webResponse.body.id.match("customfield_2")),"fieldsPresent","fieldsNotPresent")}}Please try the above-mentioned one.
Thank you for the fast reply. I tried that and didn't change the result.
Dear @Jared SchmittIf match() also didn't work, it can be because it wasn't applied to a string.Try this one, please.{{if(gt(webResponse.body.asJsonString.match("(customfield_(?:1|2))").size,0),"fieldsPresent","fieldsNotPresent")}}
Hi @Jared Schmitt
For a question like this, context is important for the community to help. Please post the following:
Until we see those...
Would you please confirm, are you testing for a match to the value of custom fields in the web response body, or to the literal text "customfield_1"?
And, there is no contains() function in smart values, and thus other methods must be used.
Kind regards,Bill
Thanks all, I went with a nested IF clause to filter for the events I'm interested in. It's quite astounding that smart values don#t support contains keyword, but oh well.
.contains() function seems to exist and work (at least for strings), but yeah, seems to have disappeared from docs?
This works for me right now in an automation rule:
1. Set variable varTest to: Hello, World!
2. Log action: {{if(varTest.contains("World!"),"Yes","No")}}
Logs: Yes
3. Log action: {{if(varTest.contains("Word"),"Yes","No")}}
Logs: No
4. Log action: {{if(varTest.contains("Hello,"),"Yes","No")}}
It looks like you're new here. Sign in or register to get started.