Arcade dictionary to FeatureSet

5631
12
Jump to solution
04-14-2021 09:59 AM
MarcHoogerwerf_TAP
New Contributor II

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

0 Kudos
12 Replies
by Anonymous User
Not applicable

Glad it was a quick find and helped out!

DavidNyenhuis1
Esri Contributor

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

0 Kudos
DavidNyenhuis1
Esri Contributor

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

0 Kudos