You need to sign in to do that
Don't have an account?
salesforce_hoonigan
Help APEX: Count Number of Notes in Parent Object
Hi All,
Please bear with me since I am a complete newbie with Apex. I need assistance building APEX to count the number of Notes (Standard Object) in Parent object (Custom Object).
I would appreciate if you can share your code.
Please bear with me since I am a complete newbie with Apex. I need assistance building APEX to count the number of Notes (Standard Object) in Parent object (Custom Object).
I would appreciate if you can share your code.
public Integer notecount{get;set;}
public Testctrl(){
notecount = [SELECT Count() From Note WHERE ParentId =: ApexPages.currentPage().getParameters().get('id') ];
}
}
AggregateResult ar=[SELECT Count(Id) num, ParentId FROM Note WHERE ParentId=:recordId GROUP BY ParentId].get(0);
system.debug('Number of notes on parent record is '+ar.get('num'));
Here, recordId is the Id of the custom object record.
Change the parent object accordingly. This might result 'No response from server' when you hit query limit.