We are using the Add Attribute Rule tool to execute an arcade script (Script 1). This is for an app we are developing. I want the script to return null in the “PlannedClosureStart” date field (line 3) when “No” is input in the “PlannedClosure” text field (line 0). However, when I try to add this the tool returns the error “ERROR 000358: Invalid expression Failed to execute (AddAttributeRule)”.
Is it possible to add null values to date fields in an arcade script?
Script 1
var PlannedStart = $feature.PlannedClosure;
if (PlannedStart=="Yes") {
return $feature.PlannedClosureStart
}
else return null
There is currently a BUG reported when you try to return a null value in Arcade: See How to return null in Arcade with Calculate Field (python works fine)?
I would probably change the expression like this (although your code does not yield a compile error):
var PlannedStart = $feature.PlannedClosure;
if (PlannedStart=="Yes") {
return $feature.PlannedClosureStart;
} else {
return null;
}
Is you field configured to allow null values?