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 -> Salesforce API: Create Multiple Objects problem

Within my Flex application, I'm trying to create multiple objects in Salesforce using the Connection create() method.
Unfortunately, the code below does not seem to be working.  I know that my basic framework works for creating a single object at a time (with the interface ISalesforceCreateable and its contract method "buildCreateableObject()" which returns an SObject.
Is there an obvious problem with how I am creating/passing my sobjectArray? 

//This method works 

public function create(createable:ISalesforceCreateable):void{

var conn:com.salesforce.Connection = SalesforceHandler.conn;

var sobject:SObject = createable.buildCreateableObject();

conn.create([sobject],this.responder,false); }


//This method does not work 

public function createMultipleObjects(createables:ArrayCollection):void{

var conn:com.salesforce.Connection = SalesforceHandler.conn;

var sobjectArray:Array = new Array();

for(var count:int=0;count<createables.length;count++){

var myCreateable:ISalesforceCreateable = createables.getItemAt(count) as ISalesforceCreateable;



conn.create(sobjectArray, this.responder,false);

trace("Created Multiple SFDC Objects, Count: " + count);



Message Edited by dturkel on 10-06-2009 05:54 AM
Best Answer chosen by Admin (Salesforce Developers) 

This appears to be programmer error.  The code I was using did not properly handle the custom external ID field values (they were non-unique).  Our fault handler was not properly built out to report errors.