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
kanupriya sharmakanupriya sharma 

foreignKeys salesforce

I need to get the foreign key columns of a table . In the describeObjectResult for the table,I get a list of child relationships but not the fk columns in this table to which the child column is mapped.
Paresh KoshtiParesh Koshti
In simple word
Every object have an ID field that is a primary key,
If you will create lookup or master-detail detail relationship on child object that will be Foreign key

Let me know if this will help you
Amol Rokade 26Amol Rokade 26
Hi Kanupriya,

Can you please try using below method:

getChildRelationships()
Returns a list of child relationships, which are the names of the sObjects that have a foreign key to the sObject being described.


Regards,
Amol
Amol Rokade 26Amol Rokade 26
Adding below URL for more info:
http://salesforce-walker.blogspot.com/2012/12/getting-child-relationshipnames-using.html
kanupriya sharmakanupriya sharma
Hi Amol.
Thanks for the reply but what I actually meant was that I have the list of childRelationships and also the chid fields which are the referenced columns for the describe object , but what I need to know is the foreing Key column in this decribed object .So for eg , if I describe Account ,I get a list of childRealtionsips and suppose COntact is a childObject for Account and getField which is the referenced column . but which column in Account is this column in Contact mapped to ?