Help get this topic noticed by sharing it on Twitter, Facebook, or email.

Inserting New Parent Child

Hello,

I see how it's possible to a child of an existing parent by adding a record to a child load table with the parent key set appropriately and then calling sf_bulkops

My question is how to load a brand new parent with child from another system in the same run of sf_bulkops as I won't have the parent id available to specify the relationship.

I know that I might be able to do this by adding the key of the other system and using that as an external key as illustrated in the SAP example in Chapter 4 of the documentation but I highly doubt tracking the other system's key in SalesForce will be an acceptable solution for this as the other system is going away in the not too distant future.

One possible workaround I see would be a two phased load with the parent loaded on the first call to sf_bulkops, and then the child on a second run using the key returned by the first load.

The external parent key would have to be added as an extra (ignored) column of the parent load table and then that same value would then be used for a lookup into the parent load table to pick up the returned parent's SalesForce key at which point a child could then be inserted into its load table.

Could someone please confirm whether this approach is viable or if there might be another built in method to do this that does not require SalesForce to store an external key?

Thanks,

Dave
1 person has
this question
+1
Reply
  • There are really 2 ways:

    1. Run SF_Bulkops 2 times: once for the parent and once for the child. When the parent run ends, the load table will contain the newly assigned Id of the parent record. Therefore, there is not a need to "read-back" or sf_refresh to get this value.

    Then, take the id, update the parent id column of the child and run the child sf_bulkops.

    2. The second way is to use external ids. This requires maintaining an external id on the salesforce side. There are still 2 sf_bulkops runs required but in the second chid run, you can use the alternate parent external id for the parent id field rather than the salesforce id.
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. sad, anxious, confused, frustrated kidding, amused, unsure, silly indifferent, undecided, unconcerned happy, confident, thankful, excited

  • Thanks for the response Bill, that's kind of what I figured.

    We'll probably implement approach number 1 maintaining our own mappings so we can support bidirectional data flow.

    Dave
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. sad, anxious, confused, frustrated kidding, amused, unsure, silly indifferent, undecided, unconcerned happy, confident, thankful, excited