function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Flex Toolkit : DescribeSObject fields are kept in Hash style

Another flex question. I couldn't find out it is intended or not.
Unlike AJAX Toolkit, describeSObject method in flex toolkit returns "fields" field as hash object, not in array.

AJAX Toolkit:

Sorry, I accicentally posted in the mid of writing.

AJAX Toolkit :
var result = sforce.connection.describeSObject('Account');
for (var i=0; i<result.fields.length; i++) {
  output += 'name: '+result.fields[i].name+', label: '+result.fields[i].label;
Flex Toolkit for Apex :
conn.describeSObject('Account', new AsyncResponder(function(result:DescribeSObjectResult):void {
  for (var name in result.fields) {
    output += 'name: '+name+', label: '+result.fields[name].label;
A little inconsistent. Is this intended?



Ron HessRon Hess
it is true that the Flex toolkit started from a port of the Ajax srcs, and some effort was made to match the api, however some things will be different between the two toolkits, this is just one of those inconsistencies. 

The associative array has the advantage that you can directly access the field if you have the name, without looping, but I doubt there was much intention put into it, just an expedient way of parsing the result object into the strongly typed Flex object.

you can re-write it as an indexed array if you like, since it's open source..