0

Can we create the child record of a parent object using the Bulk API. I am trying to use the bulk API and I want to create all the child record of a parent record. Is it possible through using bulk API? I just want to create the child record. I would like to do it in one request and mention all the childs when using the bulk api.

0

No, the bulk api is only able to work with a single object at a time.

You can, however, do this with the SOAP API.

You can create records for multiple object types, including custom objects, in one call with API version 20.0 and later. For example, you could create a contact and an account in one call. You can create records for up to 10 object types in one call.

Records are saved in the same order that they are entered in the sObjects input array. If you are entering new records that have a parent-child relationship, the parent record must precede the child record in the sObjects array. For example, if you are creating a contact that references an account that is also being created in the same call, the account must have a smaller index in the sObjects array than the contact does. The contact references the account by using an External ID field.

Edit:

Even though you can't do this in one call with the bulk API, if you have an external Id on the parent object you can use that to specify the parent for a child record in a subsequent call.

So you would create the parent records first, and then do another upload to create the child records and supplying the external id for the parent to link them.

There are details on that in the bulk API docs.

If you have a field on the parent object called ExtId__c, you can specify that in the child update as ParentObject__r.ExtId__c and the bulk api will associate them.

  • Can work with Millions of data with this? – SfdcBat Mar 2 '17 at 20:33
  • No, you can only create 200 records with a single call. – John Towers Mar 2 '17 at 20:34
  • I just added an alternative that might work with the bulk api. A single call won't work but this will get you close. – John Towers Mar 2 '17 at 20:41
  • 1
    No, you need to know which objects you're creating in advance - that means knowing the API names of the parent and child objects and the API names for all of the fields that need to be updated. – John Towers Mar 2 '17 at 21:02
  • 1
    The limit is 25 subrequests. So you should be able to create an account, contact, and 3-4 other related objects with one call to the REST API. – John Towers Mar 30 '17 at 18:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.