You need to sign in to do that
Don't have an account?

Apex Managed Sharing - Querying a Group (Role)
Hello all,
I have been trying to query the Group table to get roles with the name "Hiring Manager"
List<Group> groups = [SELECT Name, Id FROM Group where Name = 'Hiring Manager'];
hiringManagerShare.UserOrGroupId = groups[0].Id;
Can't seem to get any rows out of this. I double checked on the role's label, it is the same as above. If i remove the Where clause, everything works..
Please help!
Hi all,
I would appreciate any help on this. This is really weird because I was able to get the results if I leave out the Name clause!
I dont see any problem with the code i got the result for that by querying the same way
Thanks for the reply. I tried printing out by using system.debug and whenever I use .Name to print it, it seems to be null, what did I do wrongly? I double checked my role and the label name is correct..
I created a public group with label 'Hiring Manager' and i wrote the below query in "Developer Console" and that particular
row was fetched perfectly
List<Group> groups = [SELECT Name, Id FROM Group where Name = 'Hiring Manager'];
System.debug(groups.get(0).Name);
Sory i got your point now, if its based on role go for Developer Name field instead of Name field
List<Group> groups = [SELECT Name, Id,DeveloperName FROM Group where DeveloperName = 'HiringManagerA'];
System.debug(groups.get(0).DeveloperName );
Please mark solved if it solves your issue, so that everyone can leverage this
Cheers,
Hello,
Many thanks but this does not give me any records back either...
Still you didn't get any records from the above query? I've made some changes in query