Correct arcade label in AGOL based on if, else if and else

255
2
Jump to solution
01-19-2021 12:05 AM
Labels (1)
PeterGill2
New Contributor

Hi,

 

I am trying to create an arcade expression for my labels in the map

The following is the expression I have done - but on the second line - when I test - it says if  "assignments not be made in logical tests"

if (!IsEmpty($feature.OPERATIONALID)) {$feature.ASSETID}
else if ($feature.OPERATIONALID = $feature.ASSETID) {$feature.ASSETID}
else {$feature.ASSETID + " (" + $feature.OPERATIONALID + ")"}

What am I doing wrong.

Basic logic is:

If OperationalID is null or empty then label assetID, if operationalID = AssetID, label AssetID, else label a concatenation of assetID + OperationalID

 

0 Kudos
1 Solution

Accepted Solutions
DavidPike
MVP Frequent Contributor

I've only a basic javascript knowledge, but it seems like you have a rogue "!" before isEmpty(),

and $feature.OPERATIONALID = $feature.ASSETID is an attempted assignment without a 'var' etc. I'd say it should be a comparison operator "==" $feature.OPERATIONALID == $feature.ASSETID.

if (IsEmpty($feature.OPERATIONALID)) {$feature.ASSETID}
else if ($feature.OPERATIONALID == $feature.ASSETID) {$feature.ASSETID}
else {$feature.ASSETID + " (" + $feature.OPERATIONALID + ")"}

View solution in original post

2 Replies
DavidPike
MVP Frequent Contributor

I've only a basic javascript knowledge, but it seems like you have a rogue "!" before isEmpty(),

and $feature.OPERATIONALID = $feature.ASSETID is an attempted assignment without a 'var' etc. I'd say it should be a comparison operator "==" $feature.OPERATIONALID == $feature.ASSETID.

if (IsEmpty($feature.OPERATIONALID)) {$feature.ASSETID}
else if ($feature.OPERATIONALID == $feature.ASSETID) {$feature.ASSETID}
else {$feature.ASSETID + " (" + $feature.OPERATIONALID + ")"}
PeterGill2
New Contributor

Thanks David - works perfectly