I've had several use cases while using a when() or iif() function in Arcade where it would have been really nice to have the ability to match text using LIKE in the same way that it's used in SQL. My most recent use case is that I have several point locations on a map with a field holding website URLs. My client wants all URLs with a specific domain name (let's say www.esri.com as an example) to have different text for the hyperlink than all of the other URLs. So, I'd want to write a statement like this:
when($feature.URL LIKE "https://www.esri.com%", "Go to Esri sponsored site", "Vendor Website")
Any website that starts with https://www.esri.com would return the text "Go to Esri sponsored site" and all other sites would return Vendor Website. I can use that custom expression for the text:
And use the {URL} parameter for the actual link.
I think Find should suit this case. Let me know if it doesn't...
IIF(Find("https://www.esri.com", $feature.URL) > -1, "Go to Esri sponsored site", "Vendor Website")
Here's the documentation: https://developers.arcgis.com/arcade/function-reference/text_functions/#find
Oh nice! That worked like a charm. Thank you, Kristian!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.