Can anybody tell me the problem with the code

    public class PermissionSetCtrl {
    public List<PermissionSet> qry {get; set;}
    Public List<String> objectlist{get; set;}
    public PermissionSetCtrl(){
        List<string> objlist = new List<String>();
        qry = [SELECT Id, Profile.Name,(Select SObjectType from ObjectPerms) from PermissionSet WHERE Id IN (SELECT ParentId FROM ObjectPermissions WHERE SObjectType = 'Account' AND PermissionsRead = true)];                       
        for(PermissionSet s : qry){
            List<ObjectPermissions> listobj = qry.ObjectPerms;
            //for(ObjectPermissions ob : listobj){ }

Error : Variable does not exist: ObjectPerms

1 Answer 1


You are looping through your qry variable which is an array of PermissionSet.

If you want to access the ObjectPerms list of the PermissionSet, you will have to use the current variable in your loop. Which is s.

So here's the right code:

for(PermissionSet s : qry){
    List<ObjectPermissions> listobj = s.ObjectPerms;

You must log in to answer this question.

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