Hi,
I'm trying to convert a dictionary to a FeatureSet in an Arcade data Expression. Everything works well until I use a Date field.
The following works ok, just inserting null values for the date field
var data_dict = {
'fields': [
{'name': 'EditDate','type': 'esriFieldTypeDate'},
{'name': 'country','type': 'esriFieldTypeString'},
{'name': 'status','type': 'esriFieldTypeInteger'}
],
'geometryType':'',
'features': []
};
for (var i=0; i < 10;i++) {
data_dict.features[i] = {
'attributes': {
'EditDate': null,
'country': 'NL',
'status': 230
}
}
}
Console(data_dict)
var fs = FeatureSet(Text(data_dict))
return fs
It results in a FeatureSet with empty values for the date field and all other field filled.
However, if I try Now() or Text(Now(),"YYYY-MM-DD") or Timestamp() or just a date like string '2021-04-14' :
var data_dict = {
'fields': [
{'name': 'EditDate','type': 'esriFieldTypeDate'},
{'name': 'country','type': 'esriFieldTypeString'},
{'name': 'status','type': 'esriFieldTypeInteger'}
],
'geometryType':'',
'features': []
};
for (var i=0; i < 10;i++) {
data_dict.features[i] = {
'attributes': {
'EditDate': Now(),
'country': 'NL',
'status': 230
}
}
}
Console(data_dict)
var fs = FeatureSet(Text(data_dict))
return fs
I end up with an empty Featureset
Any ideas?
Regards,
Marc
Solved! Go to Solution.
Glad it was a quick find and helped out!
With this week's update to Arcade and ArcGIS Dashboards, date fields in feature set constructors now just work. You no longer have to wrap dates with Number() if you pass the dictionary into the FeatureSet() function (which as of this release accepts a dictionary as opposed to only text based JSON).
Instead of:
return FeatureSet(Text(dict))
Do this:
return FeatureSet(dict)
Learn more in this blog post.
NOTE: For Enterprise users, this update is targeted for 11.2
With this week's update to Arcade and ArcGIS Dashboards, date fields in feature set constructors now just work. You no longer have to pass dates in as EPOCH if you pass the dictionary into the FeatureSet() function (which as of this release accepts a dictionary as opposed to only text based JSON).
Instead of:
return FeatureSet(Text(dict))
Do this:
return FeatureSet(dict)
Learn more in this blog post.
NOTE: For Enterprise users, this update is targeted for 11.2