Heroku Connect is part of the Heroku platform used to automatically synchronize data between Salesforce and the Heroku PostgreSQL database.
Depending on your settings, when data is inserted, modified or deleted in Salesforce, Heroku Connect duplicates it in Postgre. Conversely, when data is inserted in Postgre’s tables, Heroku Connect duplicates it in Salesforce.
The Salesforce Objects structure offers a Lookup field type that is used to connect two object records together. The lookup fields contains IDs created and managed by Salesforce . You can’t create ID values from an external system.
For example, if an Object (B) has a relation to another Object (A) you can use the lookup field in Object (B) to relate it to (A) by putting record “a” ID in lookup field in record “b”.
Relationship between two objects via relationship External IDs
Unfortunately when you create Salesforce records in an external system (Postgre database in our case) you don’t immediately have access to Salesforce records IDs.
Salesforce solves this problem by allowing the child record insertion to refer to the parent record via an External ID that is inserted with the parent record.
Heroku Connect allows you to set an additional relationship field in the child record. This field is automatically created by Heroku Connect, as soon as there is a lookup link to a parent object that has an external Id, named as a combination of Salesforce ID reference/lookup field and foreign External ID you will be using.
According to the example set out above, let’s now assume that in Salesforce : – You’ve configured an External ID field called External_ID__c on the object A. – Object B has a standard lookup to Object A through the ObjectAId__c.
In Heroku Connect settings you will be automatically offered the possibility to add the field ObjectAId_rExternal_ID_c in Object B mapping page which is the relationship field you can use to relate B to A.
1. Objects structure in Salesforce
2. Heroku Connect Setting for Object B
3. Object B table structure in PostgreSQL database
How to populate these fields
You need two steps to set a relation between B and A :
Nota Bene : External IDs must be unique and unchanged over time like Salesforce IDs. Salesforce recommends using random UUIDs which can be generated using uuid_generate_v4() or gen_random_uuid() in postegre or UUID.randomUUID() in java
With Java : Assume we use JPA Repositories to manage database
Nous utilisons des cookies sur notre site internet pour vous proposer une navigation fluide en mémorisant vos préférences à chaque nouvelle visite. En cliquant sur “Accepter”, vous consentez à utiliser tous les cookies sur le site.