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

Error in trigger in production
Hi all,
Below is my trigger to update the status in the other object if the email is matched then it will update the status in the other object.
Can anyone help me over here.
Thanks in advance.
Regards,
mac.
Below is my trigger to update the status in the other object if the email is matched then it will update the status in the other object.
trigger verifyUG on UnderGradute__c (after insert) { list<string> Email = new list<string> (); list<string> phone = new list<string> (); list<Form_Leads__c> test = new list<Form_Leads__c> (); list<Form_Leads__c> test1 = new list<Form_Leads__c> (); list<Form_Leads__c> test2 = new list<Form_Leads__c> (); for(UnderLad__c IL :trigger.new){ if (IL.Email__c != null){ Email.add(IL.Email__c); } if (IL.Cell_Phone_Number__c!= null){ phone.add(IL.Cell_Phone_Number__c); } } test1=[SELECT id, Email__c, Cell_Phone_Number__c, Converted_Status__c FROM Form_Leads__c WHERE Email__c IN : Email limit 5000 ]; test=[select Cell_Phone_Number__c,Email__c, Converted_Status__c from Form_Leads__c where Id IN: test1 limit 5000]; system.debug('////'+test); for(Form_Leads__c t :test){ if(test.size()!=null){ t.Applied__c= true; t.Converted_Status__c='Matched'; test2.add(t); } } update test2; }In Sandbox it is working fine but in production it throwing an error as System.LimitException: Too many query rows: 50001.
Can anyone help me over here.
Thanks in advance.
Regards,
mac.
Can you also share the debug logs with the governor limits from the production?
Regards
RD
That is a governor limit exception. It is recommended to use Limits class to avoid such error.
I have little enhanced your trigger. Hope it works now.
Thanks
Brahma
Can you try the below code and let me know its working or not.
Thanks,
Vijay
Thanks for the replay. I changed my trigger with your code but no change in the issue. It's working fine in Sandbox but throwing the error as System.LimitException: Too many query rows: 50001. May I know why this of issue will occour in Production and not why in sandbox...?
And can you help me on this.
Thanks in advance.
Regards,
mac.
Thanks for the reply and I'm able to save the record but the fields in the Form_Leads are not updating can you please help over here.
for(Form_Leads__c t :test1){
t.Applied__c= true;
t.Converted_Status__c='Matched';
test2.add(t);
}
update test2;
}
Can I replace the IF condition ( if(test.size() > 0){ ) here..?
Thanks in advance.
Regards,
mac.
Can you try the below updated code.
Its because of the query hit
Please go through the following link (http://salesforce.stackexchange.com/questions/28228/system-limitexception-too-many-query-rows-50001)for the details
Hope it helps
RD
Have you fixed your limitation issue?? Hope my code will resolve your issue.
Thanks,
Vijay
The limitation issue is cleared but the fields are not updating.
for(Form_Leads__c t :test1){
Form_Leads__c fl = new Form_Leads__c();
if(underLeadMap.containsKey(t.Email__c)){
fl.Id = underLeadMap.get(t.Email__c);
fl.Applied__c= true;
fl.Converted_Status__c='Matched';
test2.add(fl);
}
}
update test2;
}
can you help me over here
Thanks in advance.
regards,
mac.
Still the fields are not updating. Below is my code which I have changed as per your code.
If the object having relationship means can you add relationship field in Form_Leads__c object.
Thanks,
Vijay
Thanks,
Vijay
I want to update the Converted_Status__c field in Form_Lead__c, when ever the email ID & Phone Number in the UnderLdes__c is same as the email ID and Phone Number in the Form_Leads__c.
Thanks in advance.
Regards,
mac.
Can you try the below code, Hope it will work
Error: Compile Error: Variable does not exist: f1.Id at line 24 column 9
fl.Id = t.Id
Thanks,
Vijay