Loading

MALFORMED_QUERY Error on EntitySubscription Object for Non-Admin Users

Veröffentlichungsdatum: Jun 13, 2026
Beschreibung

When a non-admin user runs a SOQL query on the EntitySubscription object without applying a LIMIT clause directly on the EntitySubscription query, the following error is thrown:
MALFORMED_QUERY: Implementation restriction: EntitySubscription only allows security evaluation for non-admin users when LIMIT is specified and at most 1000
This error occurs because the EntitySubscription object requires a LIMIT of at most 1000 when queried by a non-admin user. The LIMIT must be placed directly on the EntitySubscription query itself — applying LIMIT to an outer query or attempting to use LIMIT in a subquery does not satisfy this requirement.

Lösung

The EntitySubscription object enforces a security evaluation restriction for non-admin users. Specifically, the LIMIT of 1000 must be applied to the EntitySubscription object directly. 

MALFORMED_QUERY: Implementation restriction: EntitySubscription only allows security evaluation for non-admin users when LIMIT is specified and at most 1000

Two common incorrect approaches are:

Incorrect Approach 1: Placing the LIMIT on an outer query (e.g., SELECT Id, Name FROM Account WHERE Id IN (SELECT ParentId FROM EntitySubscription WHERE SubscriberId = '005A0000001vU2gIAE') LIMIT 1000). This does not satisfy the EntitySubscription security requirement because the LIMIT is on the Account object, not on EntitySubscription.

Incorrect Approach 2: Attempting to add LIMIT inside the subquery (e.g., SELECT ParentId FROM EntitySubscription WHERE SubscriberId = '...' LIMIT 1000 inside parentheses). This is not permitted because LIMIT cannot be used inside a SOQL subquery — Salesforce will return a parse error: "expecting a right parentheses, found 'LIMIT'."

Correct Query Pattern

Use EntitySubscription as the outer query with the LIMIT of 1000 applied directly to it, and use a subquery on the related object in the WHERE clause. For example:
SELECT ParentId, Parent.Name FROM EntitySubscription WHERE SubscriberId = '005A0000001vU2gIAE' AND ParentId IN (SELECT Id FROM Account) LIMIT 1000
This structure applies the LIMIT directly on EntitySubscription (satisfying the security restriction) and retrieves the related Account names via a subquery.

 

Nummer des Knowledge-Artikels

000386211

 
Laden
Salesforce Help | Article