Polymorphic Lookup Fields.


Table of Contents



Overview

Purpose: Polymorphic lookup fields can relate to more than one type of object. Specifying the exact type of SObject as the parent is crucial to accurately retrieve and migrate data involving such fields.

This feature enables the user to specify the parent object type for polymorphic lookup fields such as ParentId on FeedItem, and WhatId and WhoId on Activities.

How to Specify the Parent Object

To set the parent object type for a polymorphic lookup field, concatenate the name of the SObject with the name of the lookup field using a '$' separator in your SOQL query. Here is an example configuration that specifies Case as the parent type for ParentId of a FeedItem:

{
   "query": "SELECT Id, ParentId$Case FROM FeedItem WHERE Parent.Type = 'Case'"
}

This configuration ensures that the query fetches FeedItems where the ParentId is associated specifically with Case records.

Key Considerations

  • Limitation to Polymorphic Fields: This feature is applicable only to polymorphic lookup fields. It cannot be used to override the parent object for standard lookup fields.
  • Single Parent Binding: The lookup field can only be bound to one parent SObject at a time. If you require the same lookup field to be bound to different SObjects, you will need to create separate export.json configurations for each desired parent type.
  • Potential Query Errors: If the parent object for a polymorphic field is not explicitly specified, you may encounter query errors such as "No such column 'Column__c' on entity 'Name'." This error typically occurs when the system cannot determine the correct parent type for the polymorphic field.
Last updated on 20th Apr 2024