Trying to use the Calculate Field GP tool in ArcGIS Pro 2.2.3. I need to use logic (if else statements) to modify some field values.
I've searched and searched and can't find how to do this in Arcade.
In python, the following works fine. It actually sets the field to Null (verified by an isNull definition query).
return None
In Arcade, the following just returns 0
return null
I've tried a bunch of other things with Arcade, but no success.
Anyone have any ideas how to return null with Arcade?
Empty strings might be an option, since they return true from Arcade's IsEmpty() function.
Thanks Stephen. That might be an option. I've already got records that have attributes w/ Null and due to my OC tendencies, I'd like all these records to to use the same 'null' value.
I got it to work with python code, so not a huge deal, was just curious if anyone had a solution in Arcade.
Yeah, Python seems like the way to go here. It's strange that in Arcade <Null> table values return true from the IsEmpty() function, but null itself returns 0 back to the table.
I also noticed this in ArcGIS Pro. Very weird, even for a Text field assigning the Null value end up writing a 0 to the table. Kory Kramer have you seen this before?
I did a test in ArcGIS Online and created two fields (a text and a double field) and assinged Null to both fields using an Arcade expression:
In the pop-up it is not very what the actual assiged values is, so I exported the hosted feature layer to FGDB and loaded it into ArcGIS Pro to discover that there is an actual Null value in the Double Field, but the text field contains an empty string:
Thanks for pinging me, Xander Bakker! No, I haven't seen this before and after checking, I don't see any other reports of this.
Jimmy Knowles How are you!?
I'm going to run this by a product engineer on the Pro team, but unfortunately it looks like a bug to me. Basically, whenever I use Arcade to calculate null into a field (regardless of data type) it says that it succeeds and writes 0 to the field.
I tested with Text, Short and Double. So that is a bit different from what Xander saw when running the calculation in ArcGIS Online. I think we'll need to get a bug logged for this and Jimmy, I can get you attached to that when we have it. Glad that you have an easy Python workaround. I'll follow up on this soon.
Cheers
Thanks Xander Bakker for the confirmation and for testing the behavior in AGOL. Kory Kramer, thanks for the additional info as well and for working to get the bug logged. Life is good, I'll send you an email.
Jimmy: for Pro [BUG-000119064: Calculating a value to null using Arcade returns 0.]
Xander: the behavior in Online isn't as pervasive and seems to only affect Text fields [BUG-000119062: Calculating a Text field value to null using Arcade returns 0, not null.]
Hi Kory Kramer , thanks for attending this issue. You are right, it seems that the problem in ArcGIS Pro is more pervasive.
Kory Kramer, has this bug been fixed with Pro 2.4? I can't find reference to the ArcGIS Pro bug on the Esri support site under BUG-000119064 but can find the ArcGIS Online BUG-000119062 .