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
Admin DNAAdmin DNA 

without sharing declaration

Hi,
public without sharing class ClosedTaskListController { @AuraEnabled public without sharing static List<Task> getTasks(ID whoId) { return [SELECT Id, Subject, Status, CreatedDate, Owner.Name, Description, Type FROM Task WHERE isClosed=True AND WhoId=:whoId ORDER BY createdDate DESC]; } }
I have this class. Users cannot see tasks of other users despite "without sharing" declaration.
Any idea?
Thansk in advance
PawanKumarPawanKumar
Please try below.
public without sharing class ClosedTaskListController { 

@AuraEnabled public without sharing static List<Task> getTasks(ID whoId) { 
List<Task> taskList = [SELECT Id, Subject, Status, CreatedDate, Owner.Name, Description, Type FROM Task WHERE isClosed=True AND WhoId=:whoId ORDER BY createdDate DESC];
return taskList;
 }
 
}

Regards,
Pawan Kumar
Admin DNAAdmin DNA
Thank you Pawan, but user can't view the task. Could be a setting of task component in the community builder that show only actual user's tasks?