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
Satya Ranjan MohantySatya Ranjan Mohanty 

If OWD is private for a object can we give access to that object through code i mean apex class or trigger.

Pradeep SinghPradeep Singh
Hi,
Yes you can share records using apex sharing. Please go through the below link.
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_bulk_sharing_creating_with_apex.htm
Satya Ranjan MohantySatya Ranjan Mohanty
Hi Pradeep,

Thank you quick responce
can i give access to a paticuklar profile and role 

Regards,
satya
Pradeep SinghPradeep Singh
Yes you can do this, just create a public group and add roles and then use the id of the group for UserOrGroupId field.