+ Start a Discussion
Ryan O'SullivanRyan O'Sullivan 

How to utilize @readonly annotation from lightning component?

Trying to figure out how I would leverage a remoteaction/readonly scenario like I would in Visualforce but within lighting. The way lightning components communicate to Apex is similiar to the remoteaction functions as it calls a the apex function asyncrounsly. However I am doing a large aggregate query and I want to increase the 50 000 query rows touched limit. In Visualforce/Remoteaction you would declare your remoteaction function in apex with a @readonly annotation. However the system doesn't allow the @readonly annotation with the @Auraenabled annotation. I have tried declaring my functions with all three annotations (@auraenabled, @readonly, @remoteaction) but I am still hitting the 50 000 limit regardless which is telling me the @readonly functionailty isn't working. Does anyone have any adivce on how to make this possible?
Rahul KumarRahul Kumar (Salesforce Developers) 
Hi Ryan,
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.
Please refer the below link for reference. Hope it will be helpful.

Please mark it as best answer if the information is informative.so that question is removed from an unanswered question and appear as a proper solution.

Rahul Kumar
Hi Ryan,
I am facing the same issue, did you find a way to work with more thant 50000 in a lightning component ??
divya Choudharydivya Choudhary
Hi @Ryan and @Jowl , Did you find any solution to this ? I am also facing the similar issue ?