You need to sign in to do that
Don't have an account?
sandeepathadu
hi all help for 101 soql error
trigger updatetotalapps on Appointment__c(after update) { public list<appointment__c> apps {get;set;} public list<appointment__c> apps5 {get;set;} apps5 = new list<appointment__c>(); apps = new list<appointment__c>(); for(Appointment__c o:Trigger.old ) { if (Trigger.isUpdate) { appointment__c app1 =[select ID,Account__c,Name,Branch__c,Doctor__c,Appt_Date__c from appointment__c where id=:o.id]; appointment__c[] app =[select ID,Account__c,Name,Branch__c,Doctor__c,Appt_Date__c from appointment__c where Appointment__c=:app1.id]; for(appointment__c ap:app) { ap.branch__c=app1.branch__c; ap.Doctor__c=app1.Doctor__c; ap.Appt_Date__c=app1.Appt_Date__c; apps.add(ap); } } }update apps; }
this is the triiger i have written for updating of records but after certain records updaTED ITS THROWING 101 SOQL ERROR PLZ REWRITE MY CODE SO THAT I CAN AVOID THE ERROR
try this trigger
@kirtesh , nice to see you my friend :)
All Answers
Hi ,
Please Use SOQL out side of loop. Make use of List and Map to get Ids in collection form , then fire Query to get resultant data. Then Again Use List or Map to get appropriate Data.
Thanks,
Kirtesh
thanks for reply could u give me sample code how to strings and maps
try this trigger
@kirtesh , nice to see you my friend :)
thank u very much Shashikant Sharma i really wonder how exactly u r able to understand the problem and give right on answers it worked perfectly .thanks once again and hats off to u r understanding
Your welcome sandeepathadu,
I have written a lot about triggers on my blog from basic to advance cases , you can see that.
http://forceschool.blogspot.com/search/label/Apex%20Triggers
hi
can u plz give me the test case for trigger i am getting problems in it pls asap.