You need to sign in to do that
Don't have an account?

How to remove below error
Hi,
I am getting error...below code:
map<string,set<id>> contactIdAndProgramCode=new map<string,set<id>>();
for(string c:programEnrollmentAndProgramMap.values()){
for(id i:termModuleofferingModuleConnectionMap.keySet()){
contactIdAndProgramCode.put(c,termModuleofferingModuleConnectionMap.get(i));// Program code and ContactIds
}
}
Error---Invalid loop variable type expected Set<String> was String
I am getting error...below code:
map<string,set<id>> contactIdAndProgramCode=new map<string,set<id>>();
for(string c:programEnrollmentAndProgramMap.values()){
for(id i:termModuleofferingModuleConnectionMap.keySet()){
contactIdAndProgramCode.put(c,termModuleofferingModuleConnectionMap.get(i));// Program code and ContactIds
}
}
Error---Invalid loop variable type expected Set<String> was String
Please replace map<string,set<id>> to map<Set<String>,set<id>>
Let me know your review.
Thanks,
Foram rana
Hi Foram,

Nope its not working,
i need only map<string,id>
Actually i have an requiremnt I have two Map,In a new Map i have take:
in which i have to take one key from value of map 1 and one value from key og map 1.
termModuleofferingModuleConnectionMap.put(mc.hed__Contact__r.id,enRollmentId);//enrollment id and contacts
programEnrollmentAndProgramMap.put(pe.id,programCode);//enrollment id and Program code
I need Program code and ContactIds.
Thanks
Invalid loop variable type means
Either
for(string c:programEnrollmentAndProgramMap.values()) or for(id i:termModuleofferingModuleConnectionMap.keySet()) is wrong.
Can you please tell me what is the return type of programEnrollmentAndProgramMap.values() and
termModuleofferingModuleConnectionMap.keySet()
Map<id,list<Program_Session__c>> termProgramtermMap=new Map<id,list<Program_Session__c>>();
//Map term and Module offering
Map<id,list<hed__Course_Offering__c>> termModuleOfferingList=new map<id,list<hed__Course_Offering__c>>();
list<hed__Term__c> termList=[select id,name,(select id,name from Program_Sessions__r),(select id from hed__Course_Offerings__r) from hed__Term__c];
for(hed__Term__c tm:termList){
termProgramtermMap.put(tm.id, tm.Program_Sessions__r);
system.debug('termProgramtermMap' +termProgramtermMap);
}
//Map term and Module Offering
//
//Map for getting Contact and Enrollment id from Module offering //
Map<id,set<id>> termModuleofferingModuleConnectionMap=new Map<id,set<id>>();
//contact Id and Program Enrollment id
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);
system.debug('contactId' +contactId);
system.debug('enRollmentId' +enRollmentId);
//termModuleofferingModuleConnectionMap.put(mc.contactId,mc.enRollmentId);
termModuleofferingModuleConnectionMap.put(mc.hed__Contact__r.id,enRollmentId);//enrollment id and contacts
system.debug('termModuleofferingModuleConnectionMap' +termModuleofferingModuleConnectionMap);
}
}
list<hed__Program_Enrollment__c> programEnrollmentList=[select id,Program__r.Program_Code__c from hed__Program_Enrollment__c ];
map<id,set<string>> programEnrollmentAndProgramMap=new map<id,set<string>>();
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);
system.debug('Program code' +programCode);
enrollmentIDs.add(pe.id);
system.debug('enrollmentIDs' +enrollmentIDs);
programEnrollmentAndProgramMap.put(pe.id,programCode);//enrollment id and Program code
system.debug('programEnrollmentAndProgramMap' +programEnrollmentAndProgramMap);
}
// programEnrollmentAndProgramMap.put(pe.id,programCode);
// termModuleofferingModuleConnectionMap.put(mc.hed__Contact__r.id,enRollmentId)
map<string,Id> contactIdAndProgramCode=new map<string,id>();
for(string c:programEnrollmentAndProgramMap.values()){
for(id i:termModuleofferingModuleConnectionMap.keySet()){
contactIdAndProgramCode.put(c,i);
}
}
list<Program_Session__c> programTermListWithProgramCode=[select id,Program__r.id,Program__r.Program_Code__c from Program_Session__c];
map<id,string> programTermAndprogramCodeMap=new map<id,string>();
for(Program_Session__c ps:programTermListWithProgramCode){
// set<string> programCodeProgramTerm=new set<string>();
// programCodeProgramTerm.add(ps.Program__r.Program_Code__c);
programTermAndprogramCodeMap.put(ps.id,ps.Program__r.Program_Code__c); //Program term and Program code //
system.debug('programTermAndprogramCodeMap' +programTermAndprogramCodeMap);
map<string,id> updatedprogramTermAndprogramCodeMap=new map<string,id>();
for(id KeyValue :programTermAndprogramCodeMap.keySet()){
updatedprogramTermAndprogramCodeMap.put(programTermAndprogramCodeMap.get(KeyValue),keyValue);//Program code and Program Term
}
}