Skip to main content

I am trying to get data for EmailMessage SObject using REST API.

Query: SELECT Id, ParentId, ActivityId, LastModifiedDate, LastModifiedBy.Id, LastModifiedBy.Name, LastModifiedBy.Email, LastModifiedBy.Username, SystemModstamp, TextBody, HtmlBody, Headers, Subject, FromName, FromAddress, ValidatedFromAddress, ToAddress, CcAddress, BccAddress, Incoming, HasAttachment, Status, MessageDate, IsDeleted, ReplyToEmailMessageId, IsExternallyVisible, RelatedTo.Id, RelatedTo.Type, RelatedTo.Name, ContentDocumentIds FROM EmailMessage

 

I am getting MALFORMED_QUERY: Query is requesting too many junction ids; limit is 500 ERROR.

 

Need suggestions to handle this error.

2 answers
  1. Nov 14, 2024, 4:46 AM

    Hello @Vipin Sakhare,

    Salesforce has a limit on the number of junction IDs that can be queried at once. This limit is set to 500.

     

    To resolve this:

    • Reduce the number of fields you are querying.
    • Apply filters to your query to limit the number of records returned. 
    • Use the LIMIT and OFFSET clauses to paginate your results.
0/9000