2

I'm working on a little permission app for my own sanity. I'm starting with querying the Field Permissions.

I'm a bit confused with what I'm seeing.

Using Workbench:

SELECT Field,Id,ParentId,SobjectType FROM FieldPermissions WHERE Field = 'Account.Type'

My Expectation: Returns a list of FieldPermissions for the Field Account.Type Reality: This returns the Account.Type field as well as, Event.Type, Case.Type, Campaign.Type and every other Type field.

Query:

SELECT Field,Id,ParentId,SobjectType FROM FieldPermissions WHERE Field like '%Type%'

My Expectation: Return a list of FieldPermissions that have the word "Type" within the API Name Reality: This returns an error:

INVALID_QUERY_FILTER_OPERATOR: 
SobjectType FROM FieldPermissions WHERE Field LIKE '%Type%'
^
ERROR at Row:1:Column:98
invalid operator on id field

Query:

SELECT Field,Id,ParentId,PermissionsEdit,PermissionsRead,SobjectType FROM FieldPermissions WHERE Field = 'Account.Type' AND SobjectType = 'Account'

My Expectation: Returns a list of FieldPermissions for the Field Account.Type Reality: This one actually works as I expect. I'm confused why I need to specify the sObjectType twice - Once with the field API name and a second time as a separate value

Am I off base on my expectations? Why does doing a string 'like' query return an ID field error?

1 Answer 1

4

Brian. Both are bugs to one degree or another. Please make sure to file a case. It's generally a good practice to include SObjectType in your WHERE clause when querying FieldPermissions.

2
  • We'll address the lack of documentation around this. The issue with the LIKE operator has to do with the datatype. Field is a picklist, so doesn't really support LIKE. When looking for a field on an object, always include SObjectType in your WHERE clause. The '<entity>.<field>' rendering of the name is done because some fields are shared between entities, but when used in a WHERE clause, the <entity> portion is discarded (use SObjectType instead). We'll see if we can support '<entity>.<field>' in the WHERE clause, but it turns out to be harder than you might think. Nov 8, 2012 at 21:13
  • Makes sense - just seems a bit misleading if you don't know the details:) Nov 8, 2012 at 21:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .