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
Baldeep HiraBaldeep Hira 

Error using metadata API with flex toolkit

Hi Everyone,

I'm trying to use Salesforce metadata API with flex toolkit, not sure if the metadata API is fully supported and tested with flex toolkit (drop dated Feb 22, 2008)?  First off, the compiled as3Salesforce.swc library does not contain required metadata classes like CustomObject, CustomField, etc.  I figured this might be a linking problem in sample Salesforce.mxml file, as it contains no examples for metadata API.  To work around this problem, I've included the source files under toolkit/sdk/src into my flex project.  When I try to create a custom object using Connection.createObject(customObjectArray, asyncResponder) I get the following runtime error:
(com.salesforce.results::Fault)#0
  context = (null)
  detail = (null)
  faultcode = "soapenv:Client"
  faultstring = "Must specify a {http://www.w3.org/2001/XMLSchema-instance}type attribute value for the {http://soap.sforce.com/2006/04/metadata}metadata element"
My flex code looks like this:
var cf:CustomField = null;
var co:CustomObject = new CustomObject();
co.fullName = DashboardMdl.OBJECT_NAME;
co.label = DashboardMdl.OBJECT_LABEL;
co.pluralLabel = DashboardMdl.OBJECT_LABEL + "s";
co.description = "Custom object for storing SfDash dashboards.";
co.deploymentStatus = DeploymentStatus.Deployed;
co.enableActivities = true;
co.sharingModel = SharingModel.ReadWrite;

cf = new CustomField();
cf.label = "Name";
cf.type = FieldType.Text;
co.nameField = cf;

var coArray:Array = new Array();
coArray.push(co);

sfConn.createObject(coArray,
  new AsyncResponder(function (result:Object):void {
    trace("something created, perhaps Custom object!!!.");
  }, sfFault)
);
Has anyone tried using metadata API with flex toolkit?  Any suggestions?

Thanks in advance,
Baldeep Hira
http://www.bhira.net
aki3aki3

Hi Baldeep,

 

FYI

I had same linking problem and do your workaround.

Then a custom object can be created via metadata api using your code.

 

Thanks,

Aki

 

Chirag MehtaChirag Mehta

I'm trying to create custom fields from flex but I'm having hard time finding the correct syntax, can you please help or share sample piece of code that might help me in creating field.

My piece of code:

 

                var externalIdField:CustomField = new CustomField();
                externalIdField.label = 'ProductionId';
                externalIdField.type = FieldType.ID;
                externalIdField._length = 18;
                externalIdField.externalId = true;
               
                //I'm doubtful on following piece of code, as i'm not sure how do I create a pointer to a object under which i need to create field
                var customObjectVar:CustomObject = new CustomObject();
                customObjectVar. ='Agent__c';
                customObjectVar.addField(
externalIdField);
               
                objarray[0]=customObjectVar;
                con.updateObject(objarray,new mx.rpc.Responder(saveresults,sfdcFailure));

 

 

iBr0theriBr0ther

Chirag Mehta wrote:

I'm trying to create custom fields from flex but I'm having hard time finding the correct syntax, can you please help or share sample piece of code that might help me in creating field.

My piece of code:

 

                var externalIdField:CustomField = new CustomField();
                externalIdField.label = 'ProductionId';
                externalIdField.type = FieldType.ID;
                externalIdField._length = 18;
                externalIdField.externalId = true;
               
                //I'm doubtful on following piece of code, as i'm not sure how do I create a pointer to a object under which i need to create field
                var customObjectVar:CustomObject = new CustomObject();
                customObjectVar. ='Agent__c';
                customObjectVar.addField(
externalIdField);
               
                objarray[0]=customObjectVar;
                con.updateObject(objarray,new mx.rpc.Responder(saveresults,sfdcFailure));

 

 



Hello Chirag Mehta,

 

Could you please tell me where I can find (download) the metadata library so I can use such as "var externalIdField:CustomField = new CustomField();"?

 

Thanks in advance,