function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
ReeaDeveloperReeaDeveloper 

Script statements limit

Hello. I have some questions about how script statements work. If I go on a vf page and I run a piece of code of 180,000 script statements does it mean I have left 20,000 script statements for other functionality? Also using multiple classes makes the script statements for each to count and add to the controller that stated the execution?

Best Answer chosen by Admin (Salesforce Developers) 
Alex.AcostaAlex.Acosta

The current amount of script lines that get executed get reset after you get a response from your class/controller.

IE: If you you have a command button that calls a method after this completion you'll get your governor limit reset back. So if this takes 150k lines, next time you click the button you'll be able to run it again within the same session. How many lines you've executed so far use this debug statement....

 

System.debug(Limits.getScriptStatements()); 

All Answers

stcforcestcforce

don't know offhand, but can use system.debug and the methods to the Limits class to print to screen how many of any particular limit you have used and what is the maximum. I imagine it to be as simple as adding a debug statement to your method, running it with the system log (or debug log) and seeing whether the figure is reset.

ReeaDeveloperReeaDeveloper

I meant if I click something on my page and my controller runs a method that uses 180k statements and I get the response, after that can I run other code under 200k limit or have only 20k left?

Rahul SharmaRahul Sharma

I think the limit applies for per execution cycle.

Which means 20k would be left.

Try to optimize your code, by that you can save lots of Script statements.

Alex.AcostaAlex.Acosta

The current amount of script lines that get executed get reset after you get a response from your class/controller.

IE: If you you have a command button that calls a method after this completion you'll get your governor limit reset back. So if this takes 150k lines, next time you click the button you'll be able to run it again within the same session. How many lines you've executed so far use this debug statement....

 

System.debug(Limits.getScriptStatements()); 

This was selected as the best answer