Select to view content in your preferred language

Arcade Expression !IsEmpty not Functioning Correctly

158
4
Jump to solution
Monday
a_bakiera
Occasional Contributor

Hello. I have an Arcade expression in ArcGIS Online that I believe is not working correctly. It is listed below

var VisualNoWorkNeeded = DomainName($feature,"PEC_Status") == "Visual No Work Needed"
var isCompleted = DomainName($feature,"No_Access_Reason") == "Completed"
var NoAccess = DomainName($feature, "No_Access_Reason") == "Other" ||
DomainName($feature, "No_Access_Reason") == "Locked Gate" ||
DomainName($feature, "No_Access_Reason") == "Landowner Refusal" ||
DomainName($feature, "No_Access_Reason") == "Animals"
var auditAccepted = DomainName($feature,"PEC_Status") == "Accepted"; // Accepted Not Accepted
var auditNotAccepted = DomainName($feature,"PEC_Status") == "Not Accepted";
var hasWorkOrder = !IsEmpty($feature["WorkOrderNumber"]);  // string
var Assigned = !IsEmpty("");
var B = $feature["Veg_Score"] == "B"; // B C
var C = $feature["Veg_Score"] == "C";
var vegScore = $feature.Veg_Score; // C B

return When(
    auditNotAccepted, "Audit Not Accepted",
    auditAccepted, "Audit Accepted",
    VisualNoWorkNeeded, "Visual No Work Needed",
    isCompleted, "Work completed",
    NoAccess, "Unable to Access",
    hasWorkOrder, "Work order",
    Assigned, "Work assigned",
    B, "B",
    C, "C",
    vegScore
)
 
 
The problem is occurring with the part that is in bold. I am trying to get the expression to say "work order" when one exists. Right now, there are no work orders in the data and yet, every single entry is coming back with that value. I'm fairly confident that part is the problem because if I comment it out, the expression works correctly. I get the same result if I type that line like this: 
 
var hasWorkOrder = !IsEmpty($feature.WorkOrderNumber); // string
 
0 Kudos
1 Solution

Accepted Solutions
RyanUthoff
MVP Regular Contributor

Yeah, your records aren't truly null. It looks like it is just an empty string, or a value of a single space or something. If it was truly null, it would look like this:

RyanUthoff_2-1747686255604.png

 

So your Arcade expression is working correctly, you'll just need to either correct the data to make the values truly null, or you'll need to account for empty strings/spaces in your Arcade expression.

View solution in original post

4 Replies
RyanUthoff
MVP Regular Contributor

Is the data in the WorkOrder Number field truly a null value? Or could it just be an empty string with a space or something like that? As a quick test, you could try returning the value of the WorkOrderNumber variable in the Arcade expression, just to see what it is saying the value is.

0 Kudos
a_bakiera
Occasional Contributor

Here is what I got

a_bakiera_1-1747684999242.png

 

0 Kudos
RyanUthoff
MVP Regular Contributor

Yeah, your records aren't truly null. It looks like it is just an empty string, or a value of a single space or something. If it was truly null, it would look like this:

RyanUthoff_2-1747686255604.png

 

So your Arcade expression is working correctly, you'll just need to either correct the data to make the values truly null, or you'll need to account for empty strings/spaces in your Arcade expression.

a_bakiera
Occasional Contributor

Ok good deal. Thank you for catching that. I ended up nulling the records and that solved the problem!

0 Kudos