Select to view content in your preferred language

Arcade 'Schema()' function behaves differently in Pro and AGOL

227
1
09-10-2024 04:10 PM
Labels (1)
NikSandsTP
Occasional Contributor

The Arcade function 'Schema()' returns a dictionary, and within that dictionary is a 'fields' element.  This 'fields' element is an array of field schema details.

In ArcGIS Pro, this 'fields' array is ordered according to the database schema order.

In ArcGIS Online, the 'fields' array is ordered alphabetically.  At least almost alphabetically.  The 'OBJECTID' is first, and then another field (which has a coded domain), and then all other fields after that are in alphabetical order.

It is very frustrating that this behaves differently between Pro and Online!  Is there any way that I can get the 'Schema()' function to behave the same in both environments?

Ideally, I'd prefer the fields to be returned in database schema order.  Firstly, because it's easy to re-sort an array myself if I need to, but more importantly, because this is more likely to be the order that we want to see the fields in.  Alphabetical order for fields is rarely useful.  And in any case, this is not QUITE alphabetical order!

Arcade code which demonstrates the issue (view the Arcade console in AGOL):

var featureSchema = Schema($feature);
Console(featureSchema.fields);

 

0 Kudos
1 Reply
KenBuja
MVP Esteemed Contributor

Esri has two closed bug reports and an enhancement request related to this, as noted in this post

  • 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