rforce icon indicating copy to clipboard operation
rforce copied to clipboard

How can I create multiple records at once?

Open mrpersister opened this issue 14 years ago • 3 comments

Building off of the example, I've tried passing create an array of opportunities like:

binding.create :sObject => array_of_opportunities

Which throws this error:

NoMethodError (undefined method `to_sym' for #Array:0x00000004ba5488)

I'd appreciate any help.

mrpersister avatar Jan 18 '12 00:01 mrpersister

Hi, mrpersister.

I'm not sure how to do this. For the hairier API cases, it can help to start with an example of a working XML payload and work back to Ruby. I've written a couple of SalesForce API experts to ask if they can show me what this needs to look like in XML, so that we can translate it to Ruby.

--Ian

undees avatar Jan 29 '12 21:01 undees

See my response on Stack Overflow for the solution to this issue: http://stackoverflow.com/questions/8857318/ruby-rails-how-can-i-create-multiple-records-in-salesforce-with-one-api-call/9061028#9061028

ryanbrainard avatar Jan 30 '12 08:01 ryanbrainard

Thanks, Ryan!

James, the key that Ryan brings up is to have multiple :sObjects, value pairs in the array, like so:

binding.create([:sObjects, opportunity1, :sObjects, opportunity2])

Since you're the originator of the StackOverflow question, would you mind marking Ryan's answer there as accepted? (And I'll award the bounty as soon as the system lets me.)

undees avatar Jan 30 '12 17:01 undees