What is `IsSoqlCompatible` field of ListView being used for?

From the ListView Object documentation – link – there is a mention that:

IsSoqlCompatible
Description
Whether the list view can be used with SOQL..

But, I found no reference in APEX SOQL Query Docs on how to use this. I’m hoping to run an SOQL with my custom filters, PLUS want to further filter my records by passing a ListView (and this field seems important enough to identify whether a List View is compatible to be used in SOQL or not).

So does anyone knows how to use it in SOQL?

Answer

I think it essentially dictates that whether or not the list view can be generated via an SOQL.

If you run this query in console

SELECT Id, NamespacePrefix, Name, DeveloperName, IsSoqlCompatible, SobjectType
FROM ListView
ORDER BY IsSoqlCompatible

You will see that couple of object have IsSoqlCompatible as false, objects like Apex classes, lightning bundles, Visual Flow, users.

For me, some of the list views in USER objects were showing as true and some as false. So I picked the one which said false and went through each field in display and filter condition. I noticed that if the list view contains a field which is from a separate table but has a one to one relationship with User is included, the IsSoqlCompatible parameter is false.

As soon as I remove those fields, the parameter becomes true. In the case of USER, the fields were Identity verification fields like User Verified Email/Phone.


Conclusion,

Salesforce has ability to create list view spanning multiple objects which are shown as to be a single object on the UI.

These list view cannot be generated via SOQL so the parameter IsSoqlCompatible is false for them.

Attribution
Source : Link , Question Author : VarunC , Answer Author : manjit5190

Leave a Comment