I want to fetch type of hierarchy setting(profile OR User), compare it and do some logic. For that I am using setupOwner.Type in SOQL query as:
SELECT SetupOwner.Name,SetupOwner.Type,SetupOwnerId, Field1__c,
FROM MyUserSettings__c
ORDER BY SetupOwner.Name
It is giving me output as:
> SetupOwner.Type for User: 'User'
> SetupOwner.Type for profile: '00e'
> SetupOwner.Type for org: '00D'
But when I use where clause:
where SetupOwner.Type='00e'
it gives me 0 results.
How can we obtain records where type is 'Profile'? Or what is the API name of field 'Location' in hierarchy settings?
Also, I could not find official documentation for 'SetupOwner'. Is there any?
Best Answer
That is not a custom setting feature, you are referring to a polymorphic field, refer Cross-Object Owner Fields.
Now you can add filter after querying:
Credit goes to sfdcfox!
Added-
For your example, simpler would be to use following query: