Select to view content in your preferred language

Dashboard Data Expressions: What Has Changed (June 2023)

2664
1
06-15-2023 06:39 AM
Labels (1)
DavidNyenhuis1
Esri Contributor
8 1 2,664

With this past release of Arcade, the FeatureSet() function now accepts dictionaries. You may be familiar with writing the following on the last line of your data expression.

return FeatureSet(Text(dict))

This was because the FeatureSet() function only accepted JSON as text as an input. Now you can update this to...

return FeatureSet(dict)

Why is this important, you might ask. For one, it offers a performance gain. Secondly, it addresses an issue that many of you have asked to fix: Allow Date() values in date fields (esriFieldTypeDate)

When you create a feature set using the old technique, the Text() function converts Arcade dates to an ISO8601 string. However, the FeatureSet() constructor from JSON text needs an EPOCH value. So, in the past you had to wrap your dates with a Number() function (e.g., Number(Now())) before you constructed your feature set. And, if you didn’t, you’d end up with what looked like a zero-row feature set returned.

DavidNyenhuis1_0-1686682183114.png

Now that FeatureSet() accepts dictionaries, dates don’t have to be cast to EPOCH. For example, the following will now execute and return a valid feature set.

var dict = {
  fields: [{ name: "DateField", type: "esriFieldTypeDate" }],
  features: [{ attributes: { DateField: Now() } }],
  geometryType: ""
};

return FeatureSet(dict);

DavidNyenhuis1_3-1686683307113.png

That’s a wrap. Keep creating amazing dashboards.

Note for Enterprise users: This update is targeted for the 11.2 release. For previous versions you will have to utilize a technique of wrapping your dates in Number() to convert them to EPOCH and wrap your dictionary in Text() (e.g., FeatureSet(Text(myDict)) ). See this post for more detail.

1 Comment