function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Muneendar baddamMuneendar baddam 

Apex sharing rule on case object

i have two public groups ,each group have one user. when ever i created a case from group1 user that shoud be give read access  to group2 users.. by using Apex sharing...thanks 
ManojjenaManojjena
Hi Muneendar ,
First you need to check your OWD for case ,As we can extend sharing hrough sharing rule ,we can not restrict .

If you want apex sharing then you need to  write  a trigger in case .
Step1 -Event should after insert .
step2-Needs to check the loged in user is the first grop user and then needs to create a CaseShare record .
In case share caseid should the inserted case Id .
UserOrGroupId should the second gruop id or user id .
CaseAccessLevel  needs to set read only .

How ever if your OWD is private then only it will work .
Let me know any issue .

Thanks
Manoj