• Indhu priya 17
  • 10 Points
  • Member since 2018

  • Chatter
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
  • 0
I have to make all accounts into different groups based on the primary_Number__c field value and then have to assign these values to a map method. I have written the following code where I am able to pring the values of my primarynumber field but dont understand how can I make a group.
Note: I have two fields on account called Group_ID__c and Primary_Number__c where GroupID is different for every account and the PrimaryNumber is not different for every account. 

public static Map<Account, List<Account>> groupAccounts(List<Account> accounts){
Map<Account, List<Account>>  primaryNumbers = new Map<Account, List<Account>>();
Map<String, String> primaryNumberGroups = new Map<String, String>();
//groupby primary numbers
List<Id> primaryNumberIds =new List<Id>();
for(Account acc: aacounts){
primaryNumberGroups.put(acc.Group_Id__c, acc.Primary_Number__c);}
return null;

PS: promoteBusinesstoPrimaryNumbers is an another method which I have under this method where I am checking the group is having a business account or not. "groupAccounts" method I am using in my trigger handler class to get the groups of all accounts. 
Here I just want to get all the groups on the account object. Plaese help me in getting it.

Thanks in advance
Hi I am new to apex code and I am trying to caliculate the sum of the contact records where the email opt-in is about to expire. (email permission =  Date + 60 OR email permission = NULL). on Account object I want to display the count of these records. can somebody please help me with the code.

I can not create the roll up summary field as i dont have the master detail relationship in between the two objects.