1

Hi have a controller with constructor running below query

GroupMember groupMember = [SELECT Group.Name,GroupId, UserorGroupId 
                               FROM   GroupMember
                               WHERE  group.name    = 'Company A Partner Users' 
                               AND    UserOrGroupId =: UserInfo.getUserId()
                               lIMIT  1];

when I try to load the VF page that has this controller associated, I get below error.

Insufficient Privileges You do not have the level of access necessary to perform the operation you requested. Please contact the owner of the record or your administrator if access is necessary. For more information, see Insufficient Privileges Errors.

Why is this error coming and how may I fix it ?

PS - I have already assigned both the VF page and Controller access to the permission set assigned to the logged in community user.

  • Is this happening to a System Administrator profile user? Are you using the 'with sharing' in your class declaration? – Carlos Naranjo Apr 10 '17 at 12:41
  • No it is not a system administrator profile. Yes, I was using with sharing but I have tried 'without sharing' also but neither worked. – Rajeev Apr 11 '17 at 5:20
3

The answer seems pretty obvious. Your community users don't have access to the GroupMember object. I don't think it's possible to give them access to it. The only way would be to have your controller run without sharing.

  • Yes, that it is probably the reason. I executed that same query removing the group name and it works fine. So the user that is trying to run that SOQL has not access level to run this query in certain groups. ... – Carlos Naranjo Apr 10 '17 at 12:48
  • I have run controller 'without sharing' and now I am able to run the controller. Thank you both. :) – Rajeev Apr 11 '17 at 6:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.