You need to sign in to do that
Don't have an account?
Chase Maldonado
Counting Child Record data for use with LWC
Hello, I am having trouble finding a way to pull aggregate data from the below Apex class that I have for a component being built. We need to record the count of Id's and Total units from the child record ChildAccounts. I am relatively new to coding and so any information and help would be greatly appreciated!
public with sharing class GetAccountContactData { @AuraEnabled(cacheable=true) public static List<Account> getAccountData() { return [SELECT Id, Name, (SELECT Id, Name, Email, Phone, Title FROM Contacts), (SELECT Id, Name, Region_picklist__c, Total_Units__c FROM ChildAccounts) FROM Account WHERE Active__c = TRUE AND RecordTypeId = '0122K000001Dio1QAC' ORDER BY Name]; } }
Hi
You can take references from the below code.
Please mark it as the Best Answer if your queries are solved.
Thank You
All Answers
Hi Chase,
You can use the JSON.stringify(data) (data return from Apex Controller) and then iterate them.
I'm putting snippet for similar use case.
Apex Class :
JS Controller (LWC)
Hope this will give some idea.
Thanks!
Sucharita
Hi
You can take references from the below code.
Please mark it as the Best Answer if your queries are solved.
Thank You