You need to sign in to do that
Don't have an account?
Andrew Gray
aggregate list into map
Hi - basic beginner apex question but struggling.
The list TR2 will have duplicate values for Supplier__c. I want to end up with map with count of records for each Supplier__c.
What needs to go in the for loop to get this ? Thanks
The list TR2 will have duplicate values for Supplier__c. I want to end up with map with count of records for each Supplier__c.
What needs to go in the for loop to get this ? Thanks
List<Trading_Relationship__c> Tr2 = [SELECT Supplier__c FROM Trading_Relationship__c WHERE Supplier__c IN :AccIds ORDER By Supplier__c ASC]; Map<ID, Integer> Map1 = new Map<ID, Integer>(); for (Trading_Relationship__c eachTr : Tr2){ }
Solution 1:
Here is one way to handle this through Apex Solution 2:
If the Relationship between Trading Relationship and Supplier (which I thing is Account) is Master-Detail then you can create a Rollup Summary field on Account with Count and then in Apex you can do like this
Let me know if this helps
All Answers
Solution 1:
Here is one way to handle this through Apex Solution 2:
If the Relationship between Trading Relationship and Supplier (which I thing is Account) is Master-Detail then you can create a Rollup Summary field on Account with Count and then in Apex you can do like this
Let me know if this helps
Please go with any below solution:
Solution1:
Solution2:
Thanks,
Maharajan.C