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

MasterDetail Rollup
Hi
They are two objects Activity Master
Student Activities
Through programming want to create rollupsummary ( not through configuration)
Activity Master has a field No of Students Enrolled (count of records need to dispalyed here)
trigger Rollupmaster on Student_Activities__c (after insert,after update,after delete)
{
set<id> lstSet = new set<id>();
list<Activity_Master__c> lstAm = new list<Activity_Master__c>();
if((trigger.isinsert || trigger.isupdate)&& trigger.isafter)
{
for(Student_Activities__c c : trigger.new)
{
if(c.id!=null)
{
lstSet.add(c.id);
}
}
if(trigger.isdelete)
{
for(Student_Activities__c c : trigger.old)
{
lstSet.add(c.id);
}
}
for(Activity_Master__c a :[select id,No_of_Students_Enrolled__c,(select id from Student_Activities__r) from
Activity_Master__c where id =:lstSet])
{
a.No_of_Students_Enrolled__c = a.Student_Activities__r.size();
lstAm.add(a);
}
update lstAm;
}
}
Getting error in soql query Any suggestions.
They are two objects Activity Master
Student Activities
Through programming want to create rollupsummary ( not through configuration)
Activity Master has a field No of Students Enrolled (count of records need to dispalyed here)
trigger Rollupmaster on Student_Activities__c (after insert,after update,after delete)
{
set<id> lstSet = new set<id>();
list<Activity_Master__c> lstAm = new list<Activity_Master__c>();
if((trigger.isinsert || trigger.isupdate)&& trigger.isafter)
{
for(Student_Activities__c c : trigger.new)
{
if(c.id!=null)
{
lstSet.add(c.id);
}
}
if(trigger.isdelete)
{
for(Student_Activities__c c : trigger.old)
{
lstSet.add(c.id);
}
}
for(Activity_Master__c a :[select id,No_of_Students_Enrolled__c,(select id from Student_Activities__r) from
Activity_Master__c where id =:lstSet])
{
a.No_of_Students_Enrolled__c = a.Student_Activities__r.size();
lstAm.add(a);
}
update lstAm;
}
}
Getting error in soql query Any suggestions.
Try Below Code Please Mark It As Best Answer If It Helps
Thank You!
All Answers
Could you please tell the error?
Thanks!
ERROR at Row:1:Column:54
Didn't understand relationship 'Student_Activities__r' in FROM part of query call. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names.
Try Below Code Please Mark It As Best Answer If It Helps
Thank You!
Still i am getting the error
^
ERROR at Row:1:Column:60
Didn't understand relationship 'Student_Activities__r' in FROM part of query call. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names.
Could you please cross check your child relationship name once again by following this link (https://www.forcetalks.com/salesforce-topic/how-to-find-child-relationship-name-in-salesforce/#:~:text=Adarsh,-Member&text=Hello%20Ankit%2C,between%20parent%20and%20child%20objects%5D.) just navigate to Relationship Field on child Object and than appending __r with that in query.
Thanks!