function readOnly(count){ }
Don't have an account?
Search for an answer or ask a question of the zone or Customer Support.
You need to sign in to do that
Sign in to start searching questions
Signup for a Developer Edition
Sign in to start a discussion
Building on the salesforce.mxml sample:
Code:
private function describeSObjects():void { apex.describeSObjects( ["MyObject__c"], new AsyncResponder(describeSObjects_Test, genericFault)); } private function describeSObjects_Test(result:Object):void { if (result != null) { var describeSObjectResult:DescribeSObjectResult = result[0] as DescribeSObjectResult; ta.text = 'describeSObjects_Test describeSObjectResult fields = \n'; for (var fld_name:String in describeSObjectResult.fields ) { var fieldName:String = describeSObjectResult.fields[fld_name].name; ta.text += 'field = ' + fieldName + '\n'; var fieldType:String = describeSObjectResult.fields[fld_name].type; if (fieldType == 'picklist') { ta.text += ' Picklist values:' + '\n'; for (var j:int = 0;j<describeSObjectResult.fields[fld_name].picklistValues.length;j++) { ta.text += " " + describeSObjectResult.fields[fld_name].picklistValues[j].value + "\n"; } } // it's a picklist value ta.text += 'type = ' + describeSObjectResult.fields[fld_name].type + '\n'; } } }
I haven't found much info about this DescribeSObject but this is what i have so far
private function describe_Type():void{
apex.describeSObject("Product2",
new AsyncResponder(describeCallback, genericFault));
}
private function describeCallback(result: Object):void{
ta.text = 'describe Result\n' + ObjectUtil.toString(result);
}
at runtime this displays all the info about the Product2 and i can see the picklist values but this is a string.
do you know how or do you have an example of how could i have access to the values of the picklist?
thnx again!
You should be able to obtain a describeSObjectResult (dsr) and do something similar to the following
for (var i:int = 0; i<dsr.fields.length;i++) {
var field:Object = drs.fields[i];
if (field.type == "picklist") {
for (var j:int = 0;j<field.picklistValues.length;j++) {
var entry:Object = field.picklistValues[j];
trace("value: " + entry.value);
trace("label: " + entry.label);
trace("is default: " + entry.defaultValue);
trace("is active: " + etnry.active);
}
}
}
The outer for MIGHT be traversed by using
for (var fieldName:String in dsr.fields) {
...
...
}
Cheers
Building on the salesforce.mxml sample:
Code:
Be sure to change the type you're interested in in the first function.