0

I’m trying to query the EmailTemplate object in Salesforce with WITH SECURITY_ENFORCED to respect CRUD/FLS, but I get an error even though the user has access to Email Templates.

List<EmailTemplate> templates = [
    SELECT Id, Name, Subject, Body
    FROM EmailTemplate
    WHERE DeveloperName = 'Offer_Letter_Template'
    WITH SECURITY_ENFORCED
];

{
    "error": "Insufficient permissions: secure query included inaccessible field",
    "success": false
}

Why does this error occur even when access is granted?

I wrote a SOQL query on EmailTemplate with WITH SECURITY_ENFORCED because I wanted Salesforce to automatically enforce CRUD/FLS.

I verified that the user profile has access to the Email Template object and the queried fields (Id, Name, Subject, Body).

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.