+ Start a Discussion
Siddhesh KabeSiddhesh Kabe 

Getting salesforce metadata in flex


I am developing a flex component to get all the fields of a salesforce object, I use DescribeSobject  function to access the meta data.

Althought I am stuck at a place, from the server I get all the data into an array called fields, but I cannot get the fields out of the array for displaying. Can someone tell me what is wrong???


<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" 
    color="#1b0d78"    paddingTop="10" paddingRight="10" paddingLeft="10" paddingBottom="10"
              import com.salesforce.results.DescribeSObjectResult;
              import mx.logging.LogEventLevel;
               import mx.logging.LogEvent;
              import mx.managers.PopUpManager;
              import mx.validators.ValidationResult;
              import mx.controls.dataGridClasses.DataGridColumn;
             import mx.utils.ObjectProxy;
              import mx.collections.ArrayCollection;
              import mx.logging.Log;
              import mx.utils.ObjectUtil;
              import mx.controls.Alert;    
            import com.salesforce.results.Field;           
            import com.salesforce.events.*;
              import com.salesforce.objects.*;
              import com.salesforce.*;
              private function login():void {
        var lr:LoginRequest = new LoginRequest(    {
            username : '<username>',             // put your own info here to test standalone
            password : '<password>',            // put your own info here to test standalone   
            callback : new AsyncResponder(function (result:Object):void
                {     describeSObjects();
                    //ta.text = "Login successful:\n" + ObjectUtil.toString(result);
                    //loginButton.enabled = false;
                } )
            } );
        Util.debug(this, 'apex.login ( ' +ObjectUtil.toString(lr) +'\n);' );   

    // handy for debugging soap messages
    private function sendRequestListener(event:SendEvent):void {
        XML.prettyIndent = 4;
        XML.prettyPrinting = true;
        var x:XML = new XML(event.soapRequest);
        soapLog.text = x.toString();
      private function describeSObjects():void
          // this call can take one or more object names to describe in full
          apex.describeSObject("Account",new AsyncResponder(describeSObjects_CB, genericFault));
      private function describeSObjects_CB(result:DescribeSObjectResult):void
             //ta.text = 'describeSObjects_CB Result\n' + ObjectUtil.toString(result[0].Field);
             //var fields:ArrayCollection=result[0].fields;                
             if (!(result == null)) {
            // Iterate through the fields to get properties for each field
            var fields:Array=result.fields as Array;
            for(var i:int=0;i<fields.length;i++){
              var field:Field=fields[i]; //The value returned in null here.

          private function genericFault(fault:Object):void
        //ta.text = 'fault from operation: ' + ObjectUtil.toString(fault);
     <salesforce:Connection id="apex" sendRequest="sendRequestListener(event)"/>
     <mx:Label text="ActionScript Objects" fontWeight="bold" fontFamily="Courier New" fontSize="12"/>
        <mx:TextArea width="100%" height="100%" id="ta" cornerRadius="5"/>
      <mx:Label text="Soap Log" fontWeight="bold" fontFamily="Courier New" fontSize="12"/>
      <mx:TextArea id="soapLog" width="100%" height="100%" cornerRadius="5"/>
    <mx:DataGrid id="dgGrid">
            <mx:DataGridColumn dataField="label"/>


super developersuper developer

Hi ,


Did you find the solution for this then please help me.


I need the same.




I am also facing the same problem please help me.


Thanks in advance.