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

Agreegate trigger>>summry i am geting this >>error unexpected syntax: 'mismatched input 'for' expecting RCURLY'
public class AgregateFunctionOnTestObject {
public static void Afterupdate(Map<id,Test123__c> newmap,Map<id,Test123__c>oldmap){
list<id> ids= new list<id>();
for(id key: oldmap.keyset()){
Test123__c n1=newmap.get(key);
Test123__c o1=oldmap.get(key);
ids.add(key);
}
}
list<Test__c> tc= new list<Test__c>();
list<Test__c> t=[select Percentage__c,(select id from Test123s__r)from Test__c where id=:ids];
for(Test__c t1:t){
for(Test123__c r:Test123s__r){
t1.Percentage__c= t1.Test123s__r.size();
tc.add(t1);
} }
}
public static void Afterupdate(Map<id,Test123__c> newmap,Map<id,Test123__c>oldmap){
list<id> ids= new list<id>();
for(id key: oldmap.keyset()){
Test123__c n1=newmap.get(key);
Test123__c o1=oldmap.get(key);
ids.add(key);
}
}
list<Test__c> tc= new list<Test__c>();
list<Test__c> t=[select Percentage__c,(select id from Test123s__r)from Test__c where id=:ids];
for(Test__c t1:t){
for(Test123__c r:Test123s__r){
t1.Percentage__c= t1.Test123s__r.size();
tc.add(t1);
} }
}
Hi Raju,
I believe you need to make few ammendments to the code. Please see the updated code
Thanks
Vivian
list<course__c> cors=[select name, NUmberOf_Student__c,(select id,Course__c from Students__r)from course__c where id in:ids ];
// cors.NUmberOf_Student__c=cors.Students__r.size();
i want to use last commeted line how can i use it showing Variable does not exist: Students__r, how can i resolve this
Hi Raju,
cors is the parent list of Courses
Students__r is the inner list of Stidents for every individual parent (i.e Course)
Inorder to access Students__r it must be used as a variable of every parent object
Thanks
Vivian
Hi Raju,
Any progress with the development?
Thanks
Vivian
Raju,
Please feel free to close this post so that other's can also benefit from this.
Thanks
Vivian
Raju,
Add limit 10000 in the SOQL query. In case you need to display more than 10,000 records then you will need to use pagination.
Thanks
Vivian