Friday, June 24, 2016

What is Polymorphic Relationship in Salesforce ?

We are all very familiar with relationships in Salesforce right? Usually when we are discussing about relationships in salesforce immediately in our mind below listed relationship will appears

  • Lookup Relation Ship (Many-One relationship)
  • Master-detail Relationship  (Many-One relationship)
  • Many-to-Many Relationship
  • Self Relation Ship
But apart from this in salesforce we have one more relationship called Polymorphic Relationship.In all the above relationship (except Polymorphic Relationship) we always know that this particular child record always be linked to specified parent object record. For example if you have a relationship between Account(Parent) and Contact(child) that means every contact record is related any one the account record not to any ABC__c or BCD__c objects.

But where in case of Task or Events if you could see we can't guarantee that these Tasks or Events are always related to a Account records or Contact Records because these Task or Events can be linked to any one of the Contract,Campaign,Account,Opportunity,Product,Asset,Case,Solution,Quote and Any Custom Objects .These types of relationships is called as Polymorphic Relationship.In Polymorphic Relationship the referenced object of relationship can be any one of the Standard or Custom Objects.

Linking an attachment to any one of the custom object or standard object with the help of the Parent Id also refereed as Polymorphic Relationship only.

When your working with Polymorphic Relationship objects in SOQL we have several ways to access.

Follow my next to post to learn how to use this Polymorphic Relationship in SOQL.

Thanks for visiting....Enjoy!

No comments:

Post a Comment