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
RachaelCRachaelC 

Percent of Apex Used vs. Script Statement Limits

My instance of Salesforce shows that I am using only 5.96% of Apex, but at the same time, I am getting this error:

 

System.Exception: Too many script statements: 200001
[statusCode] => CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY

 

Are these things totally independent of one another?

 

How can I find out how many script statements I have? Do inactive triggers and classes count against me?

 

Thanks for the help!

 

Rachael

 

Hengky IlawanHengky Ilawan

Hi Rachael,

 

They are two different things.

The maximum amount of apex code you can use in an organization is 3MB, and you have been using 5.96% out of 3MB.

 

On the other hand, Too many script statements error was due to SF governor limits.

Please see here:

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_gov_limits.htm

 

To find out how many script statements at certain point in your code, just call the getScriptStatements method from Limits class.

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_methods_system_limits.htm

 

 

String s = 'Statement #1';
System.Debug(Limits.getScriptStatements()); // number of statements = 2 (including the debug statement)

 

Regards,

Hengky