You need to sign in to do that
Don't have an account?
surya123
Apex sharing rules on public groups
Hi,
I have a requirement to share the custom object record with a public group based on certain criteria.
for example if the record is being created by salesrep who belongs to newyork city, i have to share this record with the public group which contains all the salesreps of newyork city. all public groups for respective cities are already created in the organizations.
Can some one help me how can i query the public group based on certain criteria in this scenario.
Please provide sample code.
Thanks
those were Two options:
Option 1: Have a naming convention for your public groups that help you to query using the Name. For e.g.
select Id,Name from Group where Name='NEW_YORK Group'
Anand,
Thanks for your reply. The query that you have mentioned will not work for me since i need to share the record with public group dynamically. I cannot hard code the group name in the query. based on city names i need to get the group id dynamically to share the record.
Is there any alternative other than going for a custom object.
Thanks