December 9, 2015

@ReadOnly annotation in Salesforce

The @ReadOnly annotation allows you to perform unrestricted queries against the Force.com database. All other limits still apply. It's important to note that this annotation, while removing the limit of the number of returned rows for a request, blocks you from performing the following operations within the request: DML operations, calls to System.schedule, calls to methods annotated with @future, and sending emails.
 
A Visualforce page cannot hold more than 1000 records. But, @readOnly annotation increases this limit to 10,000. 

Only WebService, RemoteAction, or Schedulable.execute() methods can be marked read-only.
 
Using Apex, the Total number of records that can be retrieved by SOQL queries is 50,000. It is used to increase the SOQL limit from 50k to million.
 

6 comments:

  1. " The @ReadOnly annotation allows you to perform unrestricted queries against the Force.com database " .

    What exactly "By unrestricted queries" in above statement means. I can only get 1 million records in @readOnly,@RemoteAction method. Also is there any record limit while querying using rest api.

    ReplyDelete
    Replies
    1. Using Apex, the Total number of records retrieved by SOQL queries is 50,000. For REST API, check https://help.salesforce.com/articleView?id=000332074&type=1&mode=1

      Delete
  2. How to make apex:component as Readonly , i have a apex component used as a email template and when the list is having more than 1000 record i am getting a error

    ReplyDelete
    Replies
    1. Is there any way to have this sorted??

      Delete
    2. I don' think so. You can vote for this idea.
      https://trailblazer.salesforce.com/ideaView?id=08730000000ij3fAAA

      Delete