+ Start a Discussion
Frank ChenFrank Chen 

Same SOQL , but some user can't get data returned

Hi all,

 

     I got a problem, there is a SOQL   select Name from User where Name = 'records edit'

 

     In the same environment, person A can get data via this query, but person B can't.

 

     The profile and permission set is same for the two person.

 

     Do you know the reason for this problem?

 

Thanks

Best Answer chosen by Admin (Salesforce Developers) 
Bhawani SharmaBhawani Sharma
Profiles are related to schema access, but your scenario is related to data. Where roles come in picture. Options:
1. Run your class in without sharing mode
public without sharing class Controller {}
2. Add user's role to access data.
3. Share data with Person B

All Answers

Bhawani SharmaBhawani Sharma
Profiles are related to schema access, but your scenario is related to data. Where roles come in picture. Options:
1. Run your class in without sharing mode
public without sharing class Controller {}
2. Add user's role to access data.
3. Share data with Person B
This was selected as the best answer
Frank ChenFrank Chen

Hi Bhawani

 

     Thanks for your reply, the reason for this problem is  for  users whose locale is English the user's name is 'records edit', but for users whose locale is China the user's name change to 'edit records'.

 

     So Chinese user will never get data via this query.

Bhawani SharmaBhawani Sharma
Ohh..good to know. Then it should be good to query data by FirstName = 'Edit' and LastName = 'Records'.
This will not be dependent on user locale.