I am using Arcade to customise my popups in ArcGIS Online. I have a scenario where I am wanting to run one Arcade expression to return a value, and then use that value in another expression. However it is not quite working out and I am probably missing something obvious. Here is my expression:
var Status = $feature.RefStatus
var label = $feature.RefStatus; if (Status =='Ants present under artificial cover object'){
return 'Artificial cover object status: ';
} else if (Status=='Artificial cover object not found') {
return 'Artificial cover object status: ';
} else if (Status=='Artificial cover object not checked'){
return 'Artificial cover object status: ';
} else if (Status=='Current'){
return 'Waterbody status: ';
} else if (Status=='Empty'){
return 'Waterbody status: ';
} else if (Status=='Inaccessible'){
return 'Waterbody status: ';
} else if (Status=='Polluted'){
return 'Waterbody status: ';
} else if (Status=='Filled'){
return 'Waterbody status: ';
} else {
return '';
}
IIF(isEmpty($feature.RefStatus), "", label)
I want the first expression to store either the value 'Artificial cover object status: ' or 'Waterbody status: ' based on the contents of the RefStatus field, and the second expression to return the output of the first expression if the field is not empty.
Is there a way of storing an expression as a variable for use in a subsequent expression?
I have tried creating the expression separately and then referencing that expression in the 2nd one (e.g. IIF(isEmpty($feature.RefStatus), "", {expression/expr6}) but this throws an error. I have also tried assigning the first expression to a variable (e.g. var label = if (Status....) but this also does not work.
Thanks,
Rob