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
Pratap adminPratap admin 

salesforce sharing

How can we restrict access to salesforce user based on their geographic location.
Use case:- My org has users from different countries like US,UK,Japan etc. I do not want users of a location to see the data of the other locations user. Also, all users are having the same profile.

This question was asked to me in an interview. Just want to know how can we achieve this.

Thanks
surasura
set the OWD (organization Wide Sharing) to Private

then create a sharing rule to share the records to users that has the same geo location as the user
Amit Chaudhary 8Amit Chaudhary 8
Please follow below Step:-
STEP 1:- Set the organization Wide Sharing (OWD) as private.
STEP 2:- Create three role for each country
STEP 3:- Create three sharing rule for each contry and share your record with roles

Please let us know if this will help you.

Thanks
Amit Chaudhary
surasura
You can also use Apex Sharing , it has more flexibility but needs coding . since sharing rules only support groups and roles  I personnaly prefer apex sharing becuase it can be done without changing exsitng users , roles , or profiles

https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_bulk_sharing_creating_with_apex.htm