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
Suhel CruiseSuhel Cruise 

What is the significance of specifying relationship field while ingesting using Bulk v2 API ?

Hi,

Documentation here suggests that Bulk v2 API can use relationship field in header, 

https://developer.salesforce.com/docs/atlas.en-us.api_asynch.meta/api_asynch/relationship_fields_in_a_header_row__2_0.htm

But, I am also able to Ingest records of Child object without specifiying relationship (but by just specifying field name of the child Object). Then what is the need for specifying the foreign key field using relationship in header ? Am I missing something here ?

Thanks,
Suhel

 
SwethaSwetha (Salesforce Developers) 
HI Suhel,
Consider the example that, you want to create Contacts, and also connect the same to an existing Account.
If you follow this approach, the entire transaction can be taken care of in just one API call. Otherwise, you will end up making an additional API call to find the AccountId first.

This is not just limited to Bulk API but also to other APIs and Apex as well.

Hope this helps you. Please mark this answer as best so that others facing the same issue will find this information useful. Thank you
Suhel CruiseSuhel Cruise
Hi Swetha,

Thanks for your response !! But I think what you are saying is true in case of classic REST API I believe where one can create an Account and then while creating Contact can use the AccountId implicity.

But the example links given here, 
https://developer.salesforce.com/docs/atlas.en-us.api_asynch.meta/api_asynch/relationship_fields_in_a_header_row__2_0.htm

ReportsTo.Email, Mother_Of_Child__r.External_ID__c, Owner.Id - for each of these foreign key fields values are provided.respectively in separate examples:
buyer@salesforcesample.com, 123456, 005D0000001AXYz

I am assuming that these values need to be fetched using some API beforehand to be provided here So, I am not sure how can I possibly save an API call in the example you provided for Contact and Account,

I believe that while ingesting Contact, I must give and AccountId which I need to fetch (have) beforehand and must be provided for each row of Contact. 

Regards,
Suhel

 
Suhel CruiseSuhel Cruise
Any thoughts ?