Find your content:

Search form

You are here

PermissionSet API and SOQL FieldPermissions Expectations

 
Share

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?


Attribution to: Salesforce Wizard

Possible Suggestion/Solution #1

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.


Attribution to: Doug Bitting
This content is remixed from stackoverflow or stackexchange. Please visit https://salesforce.stackexchange.com/questions/4149

My Block Status

My Block Content