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
rksfdcrksfdc 

Too many script statements: 50001

I think this issue is being caused by the code throwing too many debug script than log could handle, has anyone faced this issue before? Is there an easier way or code re-factoring is the only solution?

Code:
System.Exception: Too many script statements: 50001 Class.xx.xx: line 181, column 13 Trigger.: line 52, column 43
Force.com Sandbox

Apex script unhandled trigger exception by user/organization: xx/xx

xx: execution of BeforeUpdate

caused by: System.Exception: Too many script statements: 50001

Class.xx.xx: line 181, column 13
Trigger.xx: line 52, column 43

 

JimRaeJimRae
I don't think it is caused by too many debug statements, it is caused by having too many lines of code executing in a loop. I believe the limit is 10,000 script statements per transaction.