Get the list of profiles having access to a specific object - SOQL Interview Question
This interview question on SOQL is going to make you aware of how can use SOQL and get all the profile names having access to a specific object.
Off-late a specific interview question has been asked in Salesforce Interviews a lot. That too especially when SOQL is concerned.
And the question goes like this, how can I get the list of profiles that has specific permission on a specific object?
The query goes like this!
In case you are interested in understanding how this works, continue reading.
Every profile will be associated with a Permission Set. Here is the visual confirmation for that.
The next part is, objects and their associated permissions are provided to us in the object
ObjectPermissions will have a foreign key called
ParentId which references the primary key in the object
So the below query is going to give me a list of PermissionSet
Id's and associated permissions.
Now am gonna use this list and fetch all the profile's names from the
PermissionSet object by using the
Id field (primary key) in the
I know it can be overwhelming just by the looks of it.
Try to have a look at it a couple of times and then you will get to the bottom of it.
Hope this helps!