To distribute API operations, collapse the request in another array using some agreed character (i.e :sObjects ) as the key for each value. The same character must be repeated before each value, as it is converted to duplicate XML children. For example, if you want to create two features, do the following:
opportunity1 = [ :type, 'Opportunity', :amount, '10.00', :name, 'OPP1', :closeDate, '2008-07-04', :stageName, 'Closed Won' ] opportunity2 = [ :type, 'Opportunity', :amount, '10.00', :name, 'OPP2', :closeDate, '2008-07-04', :stageName, 'Closed Won' ] puts binding.create([:sObjects, opportunity1, :sObjects, opportunity2])
This XML is created behind the scenes and sent to SFDC:
<create xmlns="urn:partner.soap.sforce.com"> <sObjects> <type>Opportunity</type> <amount>10.00</amount> <name>OPP1</name> <closeDate>2008-07-04</closeDate> <stageName>Closed Won</stageName> </sObjects> <sObjects> <type>Opportunity</type> <amount>10.00</amount> <name>OPP2</name> <closeDate>2008-07-04</closeDate> <stageName>Closed Won</stageName> </sObjects> </create>
and here is the answer to two possibilities that are created immediately:
{:createResponse=>{:result=>[{:id=>"0066000000KNMrOAAX", :success=>"true"}, {:id=>"0066000000KNMrPAAX", :success=>"true"}]}}
Note. You can create up to 200 entries at a time.
In addition, I noticed that if two values ββare the same exact object (that is, they do something like binding.create([:sObjects, opportunity1, :sObjects, opportunity1]) , the XML converter is fading, so make sure that they are actually separate objects.Probably, this is a mistake in the structure, but this is a very rare case in real production situations, which is considered serious, but keep an eye on it during testing.