[SalesForce] No such column ‘AccountNumber’ on entity ‘Name’

I am getting error 'No such column 'AccountNumber' on entity 'Name' when i tried to execute the following query,

select parent.AccountNumber, parentid, subscriberid from
EntitySubscription where parent.type='account'

How to get AccountNumber from this query? Please suggest.

Best Answer

You need to use TYPEOF to get at this data (currently only a developer preview). If you need this for production code, use two queries instead of one.

select id, typeof parentid when account then parent.accountnumber end from entitysubscription where parent.type = 'account'
Related Topic