You need to sign in to do that
Don't have an account?
AnnaT
System.LimitException: Too many code statements: 200001
When I use apex dataloader to insert multiple data, the following error occurres.
"System.LimitException: Too many code statements: 200001"
Is it because I use List ?
trigger RFTSetPDStatus on RFT_Category__c (before insert, before update) { List<Ichthys_RFT__c > msList= [SELECT RFT_Category__r.Id,Status__c FROM Ichthys_RFT__c ]; if (Trigger.isInsert) { for(RFT_Category__c pd:Trigger.new) { pd.PD_Status__c='Open'; } } else if (Trigger.isUpdate) { Integer msExist=0; Integer msCnt=0; for(RFT_Category__c pd:Trigger.new) { for( Ichthys_RFT__c ms :msList){ if( ms.RFT_Category__r.Id == pd.Id ){ msExist +=1; } } if(msExist==0) { pd.PD_Status__c ='Open'; } else { for( Ichthys_RFT__c ms :msList){ if( ms.RFT_Category__r.Id == pd.Id && ms.Status__c <>'Completed' && ms.Status__c <>'Not Applicable'){ msCnt +=1; } } if(msCnt==0) { pd.PD_Status__c ='Close'; } else if(msCnt>0) { pd.PD_Status__c ='Open'; } } } } }
Thank you,
Anna
All Answers
Thank you very much for your quick reply!!
With your support, I could update multiple data finally!
I really appreciate your support.
I'm sorry but could you help me again?
I'm trying to modify another trigger because of the same issue.
But I don't know how to filter the SOQL in this case...
Especially the following code,
" WHERE Object_No__c in :Trigger.new.Objective_No__c "
Thanks in advance for your help...
Anna
You can't do a query that way. You'll have to follow the aggregate-query-update pattern:
Aggregate: Collect the values you need to query against.
Query: Query all the matching records.
Update: Operate on the queried data.
Here's how I might implement your trigger using this method:
You'll want to read more about using Set and Map data types.
Thank you very much for your kind support!!
It works with no error !
I need to study about Map...