+ Start a Discussion
Joseph FerraroJoseph Ferraro 

flex toolkit: handling namespace prefixes

I'm rewriting a flex control to be able to handle namespace prefixing, however I'm having trouble parsing the describeSObjects call.  How do I rewrite the line below to handle a dynamic "type__c" (could be xyz__type__c or abc__type__c, etc.) field name.  I tried casting result[0].fields as an array and iterating that way, but when I trace the values, they come up as "undefined".

Code:
var myPicklistValues:ArrayCollection = result[0].fields.type__c.picklistValues;

 
thanks in advance!
rumblerrumbler
Joe,

Are you using the Flex Toolkit describeSObject call? Or are you trying to parse the SOAP response yourself?

If you are using the Flex Toolkit, then you should get an object response of type DescribeSObjectResult. In which case you would just do something like this (sorry if this isn't 100% correct, but I haven't used the Flex Toolkit for a while):

var result : DescribeSObjectResult = ...
var fieldName:String = "xyz__type__c";

var myPicklistValues:ArrayCollection = result.fields[fieldName].picklistValues;

One tip on ActionScript is to call trace(mx.utils.ObjectUtil.toString(result)), where result is the value you want to look at. It will dump the full contents of the object to the trace log so you can determine what kind of object (datatype, etc.) you are dealing with which can help resolve casting errors.

If you are parsing the SOAP Response XML (my preferred method), then I can give you a pointer on that as well.

George

Message Edited by rumbler on 11-10-2008 01:13 PM
Joseph FerraroJoseph Ferraro
thanks for the reply, I'll take a look and get back to you.
Joseph FerraroJoseph Ferraro
worked like a charm, thanks again.
prageethprageeth
Thanks Rumbler.