出于某种原因,每当我在Apex中查询EmailTemplates或文件夹时,无论用户是谁,都会返回所有EmailTemplates或文件夹。通常查询只返回当前用户有权查看的记录(至少)。如何仅查询当前用户有权访问的EmailTemplates(基于电子邮件文件夹中定义的权限)?
这是我到目前为止所拥有的:
Set<ID> FolderIds = new Set<ID>();
List<Folder> Folders = [Select Id, Name From Folder Where Type = 'Email'];
for(Folder F : Folders) { FolderIds.add(F.Id); }
List<EmailTemplate> Templates = [Select Id, Name, IsActive, Folder.Name
From EmailTemplate
Where IsActive = true
And Folder.Id IN :FolderIds
ORDER BY Folder.Name, Name];