function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Ashu sharma 38Ashu sharma 38 

Issue in Map

Hello,

i am trying to ctreate new map,in which key from Map1 and value from Map2

Map 1
  list<hed__Course_Offering__c> moduleOfferingList=new list<hed__Course_Offering__c>();
        moduleOfferingList=[select id,hed__Term__r.id,(select id,hed__Contact__r.id,hed__Program_Enrollment__r.id from hed__Course_Enrollment__r) from hed__Course_Offering__c];
        for(hed__Course_Offering__c mo:moduleOfferingList){
            set<id> contactId=new set<id>();
            set<id> enRollmentId=new set<id>();
            for(hed__Course_Enrollment__c mc:mo.hed__Course_Enrollment__r){
                contactId.add(mc.hed__Contact__r.id);
                enRollmentId.add(mc.hed__Program_Enrollment__r.id);
                
                contactsAndEnrollmentMap.put(mc.hed__Contact__r.id,enRollmentId);//enrollment id and contacts
            } 
              system.debug('contactId' +contactId);
        system.debug('enRollmentId' +enRollmentId);
            
        }

Map 2
 list<hed__Program_Enrollment__c> programEnrollmentList=new list<hed__Program_Enrollment__c>();
        programEnrollmentList=  [select id,Program__r.Program_Code__c from hed__Program_Enrollment__c ];
        map<id,set<string>> programEnrollmentAndProgramCodeMap=new map<id,set<string>>();
        if(!programEnrollmentList.isEmpty()){
            for(hed__Program_Enrollment__c pe:programEnrollmentList){
                set<id> enrollmentIDs=new set<id>();
                set<string> programCode=new set<string>();
                programCode.add(pe.Program__r.Program_Code__c);
                
                enrollmentIDs.add(pe.id);
               
                programEnrollmentAndProgramCodeMap.put(pe.id,programCode);//enrollment id and Program code
             system.debug('Program code' +programCode);
             system.debug('enrollmentIDs' +enrollmentIDs);
            }
           
        }