Select to view content in your preferred language

Arcade: Schema function returns different field order depending on application and data source

265
2
Jump to solution
08-29-2024 09:51 AM
KenBuja
MVP Esteemed Contributor

I can get the fields from a Feature or a FeatureSet using the Schema function and cycling through the fields key

 

var output = []
var fields = Schema(item).fields;
for (var f in fields) {
  Push(output, fields[f].name)
}

return { 
  type : 'text', 
  text :Concatenate(output, ', ')
}

 

For a Feature, in AGOL, the fields are returned in alphabetical order (with the exception of OBJECTID). In ArcGIS Pro, they are returned in their original order. These two screenshots use the same item from AGOL and the same code in the Arcade element

Snag_9f6d1c.png

Snag_9f910f.png

For a FeatureSet, the order of the fields depends on how I get that FeatureSet. If I get it from the map using  FeatureSetByName, the fields are returned in alphabetical order. If I get it from the Portal using FeatureSetByPortalItem, they are returned in their original order.

Snag_ac1633.png

Why isn't this consistent?

 

1 Solution

Accepted Solutions
KenBuja
MVP Esteemed Contributor

There are closed bugs and enhancement requests for these quirks

  • BUG-000152604: In Map Viewer, the Arcade $feature global variable returns fields alphabetically instead of the default field order it is published as.
    • Closed, will not be addressed:
    • Public Explanation: This issue is not addressed at this time as it is a breaking change to existing expressions.
  • ENH-000140303: Add a functionality to the map viewer to resort a field list based on the layer field or alphabetical order.
  • BUG-000144733: ArcGIS Online Map Viewer does not honor the field order for a hosted feature service.
    • Closed: Known limitation
    • Public Explanation: This is currently working as designed in the ArcGIS Online Map Viewer. There is a road map plan to add additional sort options to this field experience to take default order into account.

View solution in original post

0 Kudos
2 Replies
KenBuja
MVP Esteemed Contributor

There are closed bugs and enhancement requests for these quirks

  • BUG-000152604: In Map Viewer, the Arcade $feature global variable returns fields alphabetically instead of the default field order it is published as.
    • Closed, will not be addressed:
    • Public Explanation: This issue is not addressed at this time as it is a breaking change to existing expressions.
  • ENH-000140303: Add a functionality to the map viewer to resort a field list based on the layer field or alphabetical order.
  • BUG-000144733: ArcGIS Online Map Viewer does not honor the field order for a hosted feature service.
    • Closed: Known limitation
    • Public Explanation: This is currently working as designed in the ArcGIS Online Map Viewer. There is a road map plan to add additional sort options to this field experience to take default order into account.
0 Kudos
NikSandsTP
Occasional Contributor

Is there some way for me to be notified if/when ENH-000140303 is implemented?  Or subscribe to it, or even just to view it?  (Or can I only see enhancement requests submitted by my organisation?)

0 Kudos