I'm curious if anyone has had issues creating a data expression for Arcade in Dashboards that returns a date column?
I've noticed that if I include a date column in the FeatureSet I'm returning at the end of the script, the output contains no rows. Based on my testing I believe this is a bug in the FeatureSet() function if the dictionary you pass to it contains a date column. But since Arcade is pretty new to me maybe I'm doing something wrong
As an example, I put two samples below of the same code based on a public facing AGOL hosted feature layer. The first sample has the date column removed so you can see it does return data. The second sample the only difference is the date column is included, but you'll notice if you run it the results are blank. I tried this with two AGOL feature layers, so it doesn't seem to be a fluke with just one layer.
I'm trying to follow along on the GitHub example on how to join tabular data to one of my layers and returns a feature set (Link). Ultimately I want to slice and dice the layer in Arcade, but for this forum question I kept the script simple to show the issue.
Here's sample script 1 with the date column commented out. If you run in the Arcade playground you will se it returns data.
var portal = Portal("https://www.arcgis.com/");
var features = [];
var feat;
//Define input layer to read
var fs = FeatureSetByPortalItem(
portal,
"a400f4711f9443a9855340ee7b66890a",
0,
['DRAINAGE_ID','LOCATION','FME_DATE'],
false
);
//Loop over each hosted layer feature
//, pass subset of attribute values to the feat variable
//, then Push the feat object into the feature dictionary
for (var f in fs) {
feat = {
attributes: {
DRAINAGE_ID: f["DRAINAGE_ID"],
LOCATION: f["LOCATION"],
//FME_DATE: f["FME_DATE"],
}
}
Push(features,feat)
}
//Define schema for output dictionary
//and pass in the dictionary of output features
var joinedDict = {
fields: [
{name: "DRAINAGE_ID", type: "esriFieldTypeInteger"},
{name: "LOCATION", type: "esriFieldTypeString"},
//{name: "FME_DATE", type: "esriFieldTypeDate"}
],
'geometryType': '',
'features':features
};
return FeatureSet(Text(joinedDict));
Here is sample 2 that includes the date column, but when you run it the results will be blank
var portal = Portal("https://www.arcgis.com/");
var features = [];
var feat;
//Define input layer to read
var fs = FeatureSetByPortalItem(
portal,
"a400f4711f9443a9855340ee7b66890a",
0,
['DRAINAGE_ID','LOCATION','FME_DATE'],
false
);
//Loop over each hosted layer feature
//, pass subset of attribute values to the feat variable
//, then Push the feat object into the feature dictionary
for (var f in fs) {
feat = {
attributes: {
DRAINAGE_ID: f["DRAINAGE_ID"],
LOCATION: f["LOCATION"],
FME_DATE: f["FME_DATE"],
}
}
Push(features,feat)
}
//Define schema for output dictionary
//and pass in the dictionary of output features
var joinedDict = {
fields: [
{name: "DRAINAGE_ID", type: "esriFieldTypeInteger"},
{name: "LOCATION", type: "esriFieldTypeString"},
{name: "FME_DATE", type: "esriFieldTypeDate"}
],
'geometryType': '',
'features':features
};
return FeatureSet(Text(joinedDict));
//If you instead return just the Text(joinedDict) you will see that the data looks valid
//, so it's just way the FeatureSet() function is transforming the data that seems to cause blank results
//return Text(joinedDict)