I am new to Salesforce and currently trying to query the fields from the Store object related to the OrderSummary standard object. Store has a lookup relationship with OrderSummary object.
First, I tried to do a normal child->parent SOQL query but received below error
Select Id, SalesStore.Description from OrderSummary where Id = 'MY_ID'
No such column 'Description' on entity 'Name'
Upon some research I found that this maybe because the field is polymorphic. I ran below code and the result of method isNamePointing
is true.
System.debug(OrderSummary.SalesStoreId.getDescribe().isNamePointing());
Then I tried using the TYPEOF
clause as below but got another error.
Select Id, TypeOf SalesStore When Store Then Description END from OrderSummary where Id = '1Os7a0000004DWSCA2'
sObject type 'Store' is not supported.
I also tried another variant of TYPEOF
clause as below but got another error
Select Id, TypeOf SalesStoreId When Store Then Description END from OrderSummary where Id = '1Os7a0000004DWSCA2'
No such relation 'SalesStoreId' on entity 'OrderSummary'.
So, how can I query the fields of the Store object associated with the OrderSummary object.
Data Model
Select Id, TypeOf SalesStoreId When WebStore Then Description END from OrderSummary where Id = 'MY_ID'
No such relation 'SalesStoreId' on entity 'OrderSummary'.
Select Id, TypeOf SalesStore When WebStore Then Description END from OrderSummary where Id = 'MY_ID'