Arcade not working in new map viewer

959
4
Jump to solution
03-24-2022 11:28 AM
Big-Chill
New Contributor III

Hey folks, am I missing something within this new map viewer?  Super frustrating to work with Arcade Expressions.  I am using the following document without any success Introducing Arcade pop-up content elements .  When referencing a variable the format described in the document does not work.  For example, using the Rich Text Template:

var cpoName = IIF(IsEmpty(Trim($feature.CPONAME})),"","CPO Name: ");

return {
"type" : "text",
"text" : '${cpoName}' //this property supports html tags
}

However, when I remove the quotes - all is good.  Am I missing something or is the documentation that bad?  I understand it's a big transition from Classic to the New Viewer but the functionality should be the same.  Anyway, has anyone else experienced this.

Jim L.

0 Kudos
1 Solution

Accepted Solutions
KenBuja
MVP Esteemed Contributor

It looks like you're not using the correct symbol in the text property. Instead of using a quote ('), use the backtick(`). See this blog for information about string template literals: https://www.esri.com/arcgis-blog/products/arcgis-online/mapping/manage-your-strings-quite-literally-...

View solution in original post

4 Replies
KenBuja
MVP Esteemed Contributor

It looks like you're not using the correct symbol in the text property. Instead of using a quote ('), use the backtick(`). See this blog for information about string template literals: https://www.esri.com/arcgis-blog/products/arcgis-online/mapping/manage-your-strings-quite-literally-...

Big-Chill
New Contributor III

Thank you for the helpful tip.  Kind of goes against most coding/scripting techniques, no?  I don't ever remembering using backticks.  A bit weird but at least it works.  Thanks

0 Kudos
KenBuja
MVP Esteemed Contributor

The template literal was introduced in JavaScript with the ES6 revision and is used quite commonly in that.

0 Kudos
Big-Chill
New Contributor III

Exclusive to JavaScript and Arcade.  Got ya.  Thank for the tip.

0 Kudos