You need to sign in to do that
Don't have an account?

Technique to avod "Too many script statements"? when populating lookup field
I have an object A with a lookup field to another object B. There are approximately 500 records of object A in the database. I want to populate that lookup field in those existing records with the appropriate record relationship to Object B. Object B already has a lookup field to object A, so I need to check to see if Object B looks up to Object A, and if it does, I need to associate that record to Object A.
This is already inside an @future call. I'm getting the too many script statements error. Any advice would be most appreciated!
@future
public static void addCurrentRPPA() {
Active_Project__c[] projects = [select id,name from Active_Project__c];
Active_Project__c[] updateProjects = new Active_Project__c[0];
for (Active_Project__c proj:projects) {
String projId = proj.id;
Rate_Profile_Project_Assignment__c rp;
for (Rate_Profile_Project_Assignment__c rate:rateAssignments) {
if (rate.Projects__c==proj.id) {
rp = rate;
}
}
if (rp!=null) {
proj.rate_profile_project_assignment__c = rp.id;
updateProjects.add(proj);
}
}
update updateprojects;
}
use maps....that will avoid for loops...therby reducing the no. of script statements....
All Answers
use maps....that will avoid for loops...therby reducing the no. of script statements....
I am getting the same error please help me
System.LimitException: Too many script statements: 200001