Arcade expression to display two concatenated fields with domains

2289
5
02-24-2022 03:26 AM
Labels (2)
AlbertJordana
New Contributor

Hi all, 

I am quite new to arcade so forgive me if the answer is way too obvious to everyone...

I'm trying to use arcade to change the symbology so it displays two different fields, each one with its own domain.

The fields are cleanseStatus and cycle. Both have a domain as well

I have used the expression:

($feature.cleanseStatus) + "," + ($feature.cycle)

But I only get the code for the cleanse status, and nothing for the cycle and also get the code for the different cleanseStatus and not the description.

Ideally I would like to see the cleanse status code description, then a coma, and then the cycle code description so I can adjust the symbology for each one independently.

Thanks a lot in advance.

Albert

 

 

0 Kudos
5 Replies
AlbertJordana
New Contributor

Quick update. 

By using the following expression I get the code for each field, but not the description..

DomainName($feature,"cleanseStatus") + ',' + DomainName($feature,"cycle")

0 Kudos
jcarlson
MVP Esteemed Contributor

@HalaAbdelmaksoud  has what ought to be the solution here, but it's odd that it wouldn't work for your data.

My only suggestion in addition to that would be to use a backtick string and some variables to help keep the code a bit clearer.

Try this expression and click Test in the expression builder, then see what the Messages tab shows you.

var status = DomainName($feature, 'cleanseStatus')
var cycle = DomainName($feature, 'cycle')

// Send variables to console to check their values
Console(status)
Console(cycle)

// Return formatted string
return `${status}, ${cycle}`
- Josh Carlson
Kendall County GIS
0 Kudos
AlbertJordana
New Contributor

I get this error 

"Parse Error:Line 9: Unexpected token ILLEGAL"

The funny thing is that I have tried with another dataset and the previous expressions works just fine, so I don't know what's preventing from returning correctly for this dataset
0 Kudos
jcarlson
MVP Esteemed Contributor

Did you get anything in the messages tab?

Also, where is this data coming from? Is it possible that the source portal is at a lower version with fewer capabilities in Arcade?

- Josh Carlson
Kendall County GIS
0 Kudos
HalaAbdelmaksoud
Occasional Contributor

I have tried this way: DomainName($feature,"Field1") + "," + DomainName($feature,"Field2") but with my data, and it works well.