You need to sign in to do that
Don't have an account?
Vishwanath
"System.LimitException: Too many script statements: 200001 'Extarnal entry point" in test class
HI,
Please any one, help me to solve this issue
"System.LimitException: Too many script statements: 200001 'Extarnal entry point" in test class
this error is occure when im going to run the test class
Controller:
public class paymentinvoicepdf { public paymentinvoicepdf(ApexPages.StandardController controller) { } Public List<UOP_Aggregation_Group__c> agroup{get;set;} public String contname{get;set;} public String title{get;set;} public String Email{get;set;} public String Telephone{get;set;} public Boolean flag{get;set;} //{get;set;} public Royalty_Contacts__c rc{get;set;} public List<Royalty_Contacts__c> rc1{get;set;} public List<Royalty_Contacts__c> rc2{get;set;} public PageReference royalcon() { Id id=Apexpages.currentpage().getparameters().get('id'); UOP_Royalty_Payment_History__c urp=[select id,name,Process_Unit__r.Account__r.UOP_CA_S_Account_Manager__c,Payment_History_Event__c,Invoice_Number__c,Invoice_Date__c from UOP_Royalty_Payment_History__c where id=:id]; id urpid=urp.Process_Unit__c; rc1=[select id,name,contact__r.name,Royalty_Role__c,Title__c,Phone__c,Email__c from Royalty_Contacts__c where Process_unit__r.id=:urpid and Royalty_Role__c=:'Royalty (Primary)']; if(rc1.size()>0) { flag=true; } rc2=[select id,name,contact__r.name,Royalty_Role__c,Title__c,Phone__c,Email__c from Royalty_Contacts__c where Process_unit__r.id=:urpid and Royalty_Role__c=:'Royalty (Secondary)' and Royalty_Role__c=:'Royalty (Primary)' ]; if(rc2.size()>0) { flag=false; } /*for(Royalty_Contacts__c r:rc1) { if(r.Royalty_Role__c=='Royalty (Primary)') { flag=true; contname=r.Contact__r.name; title=r.Title__c; Email=r.Email__c; Telephone=r.Phone__c; //rc=[select id,name,contact__r.name,Royalty_Role__c,Title__c,Phone__c,Email__c from Royalty_Contacts__c where Process_unit__r.id=:urpid and Royalty_Role__c=:'Royalty (Primary)']; } else if(r.Royalty_Role__c=='Royalty (Secondary)') { flag=false; } }*/ Process_Unit__c pu=[select id,name,Aggregation_Group__c from Process_Unit__c where id=:urpid]; id aid=pu.Aggregation_Group__c; agroup=[select id,name,(select id,name,Aggregation_Group__c,Unique_Process_Unit_Identifier__c from Process_Units__r) from UOP_Aggregation_Group__c where id=:aid]; return null; } }
test class:
@istest() public class paymentinvoicepdftest { public static testmethod void test() { UOP_Royalty_Payment_History__c uopCreat=new UOP_Royalty_Payment_History__c(Payment_History_Event__c='Report'); ApexPages.StandardController accCtrl = new ApexPages.Standardcontroller(uopCreat); paymentinvoicepdf pay=new paymentinvoicepdf(accCtrl ); Account ac=new Account(name='test'); //ac.SAP_Customer_Info__c=s.id; insert ac; Process_Unit__c pu=new Process_Unit__c(name='testAccount',Account__c=ac.id,Status__c='Licensed',Technology_Supplier__c='ABB Lummus', Units_Fully_Paid_Capacity__c='Accounting Units',Agreement_Status__c='Fully Executed',License_Type__c='Unit',Subject_To_Audit__c='yes', Current_Royalty_Type__c='Fully Paid',UOM_Capacity__c='BPSD'); insert pu; UOP_Royalty_Payment_History__c uop=new UOP_Royalty_Payment_History__c(Payment_History_Event__c='Report',Process_Unit__c=pu.id, Royalty_Rate__c=0.50,Applicable_BLS__c=10,BLS_Base__c=100,UOP_Year__c='2001',Overage__c=11000); insert uop; ApexPages.currentPage().getParameters().put('id',uop.id); UOP_Royalty_Payment_History__c urp=[select id,name,Process_Unit__r.Account__r.UOP_CA_S_Account_Manager__c,Payment_History_Event__c,Invoice_Number__c,Invoice_Date__c from UOP_Royalty_Payment_History__c limit 1]; List<Royalty_Contacts__c> rc1=[select id,name,contact__r.name,Royalty_Role__c,Title__c,Phone__c,Email__c from Royalty_Contacts__c where Process_unit__r.id=:urp.id and Royalty_Role__c=:'Royalty (Primary)']; Process_Unit__c pu1=[select id,name,Aggregation_Group__c from Process_Unit__c where id=:pu.id limit 1]; UOP_Aggregation_Group__c a=new UOP_Aggregation_Group__c(name='test'); insert a; List<UOP_Aggregation_Group__c> agroup=[select id,name,(select id,name,Aggregation_Group__c,Unique_Process_Unit_Identifier__c from Process_Units__r) from UOP_Aggregation_Group__c where id=:a.id]; pay.royalcon(); } }
Give me some suggestions how to solve this issue
Thanks,
Vishwa A
Hi,
One question before I answer, is the comments for loop - uncommented in your actual code?
As other than the for - loop your code looks pretty concise and I amamazed what is causing the - too many scripts expection ...
Alsoplease do specify when is the called invoked and as the objects get created and modified are there any workflow rules or triggers acting on the involved objects.
Hi,
There is a governor limits for an apex code script statements of 2, 00,000 which exceeded in your code of 200,000 script statement. You can try by removing this field Process_Unit__r.Account__r.UOP_CA_S_Account_Manager__c in your query.
Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.
Hi Ispita,
yes Ispita as u told, This object have an trigger for update and isert, when i inactive the trigger my test class of this controller is working fine,but when it active it will displaying error , and the trigger test class is covering 97% of code.
please let me know how come i can solve this issue
Here is my trigger:
Hi,
Generally one tries to keep the for loops to the minimum in a trigger and in your trigger there are lets say :-
Hope this helps....
Hi Ispita,
Thanks for your peplay
please give some suggenstion how can i reduce the foor loop in my trigger,
Thanks,
Vishwa A
Wherever you are using an array of records try using an :-
Hi Ispita,
What im going to achiev is
i have object A <--- B <--- C
A is parent to B, and B is Parent to C
assume in A1 records have near about 100 of child record (Ex ; b1,b2,b3,b4,b5.....................)
when i insert c1 child in b1 parent, it should be insert in all b2,b3,b4,b5..................... (Ex ; b1 <-- c1, b2<--c2, b3<--c3 ,........)
and if i update any one it should be update in all
it will fine as i written in above trigger, problem with this is Too many script statements: 200001 'Extarnal entry point"
please give me some code solution
Thanks,
Vishwa A
Is there any reason that you need to update so many records in your TEST class? I also experience something similar before when I use Dataloader to upload data. My thought is, you could just create a simple TEST class to just update one record but of course have some coverage of your code. When you do bulk uploading, you could set the batch size to a smaller amount. This would take longer time to load but prevent this exception. Hope this helps.