I have an Arcade expression on my popup which returns fields.
If the field type is an esriFieldTypeDate, we format the field as 'ddd DD MMM YYYY'. Opening the map in a browser the date displays correctly, e.g. 'Tue 19 Nov 2024'. However on Field Maps it's displaying as a long timestamp, e.g. '1731991427000'.
Is this a bug or am I doing something wrong?
Relevant Arcade code follows:
Solved! Go to Solution.
Thanks for your answer @ChristopherCounsell.
It turned out to be much more obscure. I'd omitted to give you the preceding code, which I'd created from @PaulBarker's article Introducing Arcade pop-up content elements:
// Get field metadatavar fieldMeta = {};for (var f in fields) {var fieldName = fields[f].name;if (HasKey(validFieldsSet, fieldName)) {fieldMeta[fieldName] = {alias: fields[f].alias,domain: HasKey(fields[f], "domain"),fieldType: fields[f].type,name: fieldName};}}
The problem is that HasKey(fields[f], "domain") returns true on Field Maps, but false on Web Maps.
I've solved it by changing this line to also check for an empty domain value:
domain: HasKey(fields[f], "domain") && !IsEmpty(fields[f].domain),
and the date fields now display as desired.
Any chance someone at ESRI could update the Introducing Arcade pop-up content elements article with this solution so others don't get the same problem?
It's your return statement casting it as type:fields.
Field maps is returning the text() back as the the field type, which is date, so it converts the text(date) back to epoch time.
You could try forcing the function to return it as a text e.g.
return Text(fieldValue, 'ddd DD MMM YYYY') + "";
Or update the final return statement to return text, as html or something like this:
return {
type: "text",
text: attributes[alias]
};
Thanks for your answer @ChristopherCounsell.
It turned out to be much more obscure. I'd omitted to give you the preceding code, which I'd created from @PaulBarker's article Introducing Arcade pop-up content elements:
// Get field metadatavar fieldMeta = {};for (var f in fields) {var fieldName = fields[f].name;if (HasKey(validFieldsSet, fieldName)) {fieldMeta[fieldName] = {alias: fields[f].alias,domain: HasKey(fields[f], "domain"),fieldType: fields[f].type,name: fieldName};}}
The problem is that HasKey(fields[f], "domain") returns true on Field Maps, but false on Web Maps.
I've solved it by changing this line to also check for an empty domain value:
domain: HasKey(fields[f], "domain") && !IsEmpty(fields[f].domain),
and the date fields now display as desired.
Any chance someone at ESRI could update the Introducing Arcade pop-up content elements article with this solution so others don't get the same problem?