Hi,
I'm trying to transfer date data from a source feature class to a target feature class using an Arcade Dictionary to update the date field in the target class. Some of the features in the source class have blank\null value in the date field.
When the rule finds one source features with a blank\null field it raises and error saying that the value passed by the dictionary to the field is not the right type. Even when the date field in the target is set to allow null values.
Then, I found that setting the date field value in the dictionary explicitly to null will avoid the error, but the value was set to "12/30/1899" in the target date field.
Why is not possible to set date field value to null using an Arcade Dictionary?
Solved! Go to Solution.
Hey Billy,
Do you know which ArcGIS Pro/Enterprise you are running?
We had a bug with Null persistence in Arcade that we fixed in Pro 2.8 (Enterprise 10.9).
So, what about using the if a little differently, and just omit the field entirely if the value is null? Also, by establishing the attributes dict atts directly, you can just skip past creating all those intermediate vars.
var atts = {
'phasesnormal': transf_phase,
'phasescurrent': transf_phase,
'phasessummer': transf_phase,
'phaseswinter': transf_phase,
'addpowerrating': closestf['Bayonet_fuse_rated_amp']
}
if(IsEmpty(closestf['InstallationDate'])){
atts['installdate'] = closestf['InstallationDate']
}
if(IsEmpty(closestf['TapDate'])){
atts['inservicedate'] = closestf['TapDate']
}
return {
'result': field_value,
'edit':[{
//updates the fuse feature attributes
'className': 'UN_MODEL_V34.MODEL_V34.ElectricDevice',
'updates': [{
'globalID': $feature.globalID,
'attributes': atts
}
}]
}]
}
}
Any chance you could share the code being used here? It's hard to understand how your process is breaking down without some more specifics. If you're just updating a single field, why use a dictionary? Couldn't you pipe the value straight from one to the other? And use an if statement to skip the null values?
Hi Josh,
Thanks for your answer. Below you can see the section of the code where the assignment is done and the returned dictionary is defined. Before this section the code is just finding the closest source feature, which is not related to the problem.
As you can see, I'm updating multiple fields, hence the used of the dictionary. The IF statement is the workaround that I mentioned in the third paragraph of my original question.
Below you can see images with the field view in ArcGIS Pro for the source class and the target class.
// Extract fuse attributes from closest source feature
var fuse_addpowerrating = closestf['Bayonet_fuse_rated_amp'] // This is the fuse rated current
var fuse_installdate = closestf['InstallationDate'] // Fuse installation date
var fuse_inservice_date = closestf['TapDate'] // Fuse inservice date
var phasesnormal = transf_phase // Domain assign to field
var phasescurrent = transf_phase // Domain assign to field
var phasessummer = transf_phase // Domain assign to field
var phaseswinter = transf_phase // Domain assign to field
if (IsEmpty(fuse_installdate) || IsEmpty(fuse_inservice_date) ) {
fuse_inservice_date = null
fuse_installdate = null
}
// Return dictionary with the data to transfer to the target feature
return {
'result': field_value,
'edit':[
{
//updates the fuse feature attributes
'className': 'UN_MODEL_V34.MODEL_V34.ElectricDevice',
'updates': [{
'globalID': $feature.globalID,
'attributes': {
'phasesnormal': phasesnormal,
'phasescurrent': phasescurrent,
'phasessummer': phasessummer,
'phaseswinter': phaseswinter,
'addpowerrating': fuse_addpowerrating,
'installdate': fuse_installdate,
'inservicedate': fuse_inservice_date,
//'model': fuse_model
}
}]
}
]
}
}
Source Feature Date Fields
Target Feature Date Fields
So, what about using the if a little differently, and just omit the field entirely if the value is null? Also, by establishing the attributes dict atts directly, you can just skip past creating all those intermediate vars.
var atts = {
'phasesnormal': transf_phase,
'phasescurrent': transf_phase,
'phasessummer': transf_phase,
'phaseswinter': transf_phase,
'addpowerrating': closestf['Bayonet_fuse_rated_amp']
}
if(IsEmpty(closestf['InstallationDate'])){
atts['installdate'] = closestf['InstallationDate']
}
if(IsEmpty(closestf['TapDate'])){
atts['inservicedate'] = closestf['TapDate']
}
return {
'result': field_value,
'edit':[{
//updates the fuse feature attributes
'className': 'UN_MODEL_V34.MODEL_V34.ElectricDevice',
'updates': [{
'globalID': $feature.globalID,
'attributes': atts
}
}]
}]
}
}
Hi Josh,
Your code looks like another way to avoid the error with lest code, and it should save me the work to find all the feature that were assigned the date "12/30/1899" and replace it with a field calculation process in the attribute table.
I will test it and report back the result.
Thanks.
Test went well. But I made a small change to the IF statements. It should be " If Not Empty" --> If (!IsEmpty()){}
Here is the updated code:
var atts = {
'phasesnormal': transf_phase,
'phasescurrent': transf_phase,
'phasessummer': transf_phase,
'phaseswinter': transf_phase,
'addpowerrating': closestf['Bayonet_fuse_rated_amp']
}
if(!IsEmpty(closestf['InstallationDate'])){
atts['installdate'] = closestf['InstallationDate']
}
if(!IsEmpty(closestf['TapDate'])){
atts['inservicedate'] = closestf['TapDate']
}
return {
'result': field_value,
'edit':[{
//updates the fuse feature attributes
'className': 'UN_MODEL_V34.MODEL_V34.ElectricDevice',
'updates': [{
'globalID': $feature.globalID,
'attributes': atts
}
}]
}]
}
}
Hey Billy,
Do you know which ArcGIS Pro/Enterprise you are running?
We had a bug with Null persistence in Arcade that we fixed in Pro 2.8 (Enterprise 10.9).
Hi,
I'm running Pro 2.8, but Enterprise 10.8.1
Can you try your rule on a FileGDB? see if you experience the behavior. If you don't, then we know this bug was fixed in 2.8 and Enterprise 10.9 will have the fix.
I will test it and get back to yo with the result.
Let me take the opportunity to see if you can take a look at this question that I posted about copying attachments with Arcade:
Copy Pictures Taken with Field Maps to Utility Net... - Esri Community
Thanks.