You need to sign in to do that
Don't have an account?
second largest value of child object(roll up summary) using trigger
hi all,
i am trying to find the second largest value of my child record using trigger but i am getting error ...any help
this is my code.
i am geting following error ...Compile Error: unexpected token: '(' at line 20 column 100
trigger secoundlargest on object2__c (after insert,after update,after undelete)
{
Map<Id,object1__c> ohh = new Map<Id,object1__c>();
set<id> ids=new set<id>();
try
{
if(trigger.isinsert||trigger.isupdate||trigger.isundelete)
{
for(object2__c oid:trigger.new)
{
ids.add(oid.Object1__c);
}
Ids.remove(null);
for(id idss:ids)
{
ohh.put(idss,new object1__c(id=idss,grandtotal__c=0));
}
for(object2__c sd:[select name,(SELECT MAX(total__c) FROM object2__c WHERE total__c < (SELECT MAX(total__c) FROM object2__c)) from object2__c WHERE object1__c IN: ids])
{
}
}
}
catch(Exception e)
{
System.debug('### Exception: ' + e.getMessage());
}
}
i am missing something ...
regard,
jaba
Hi
You have to use Object2__r in the nested child query and also check the brackets are opened and closed properly.
If this post solves your problem kindly mark it as solution. if this post is helpful please throw Kudos.
Thanks