0

I have declare the collections in trigger code:

Set<String> markets = new Set<String>();
Map<string, Map<Date,Holiday__c>> holidays = new Map<string, Map<Date,Holiday__c>>();
for(String market: markets) {
   holidays.put(market, new Map<Date, Holiday__c>());
}
for(Holiday record: [SELECT Date__c, Country__c FROM Holiday__c WHERE Country__c = :markets]) {
   holidays.get(record.Country__c).put(record.Date__c, record);
}

But for this Line it is showing error: holidays.get(record.Country__c).put(record.Date__c, record);

Country__c is a Picklist type in salesforce

Error: Compile Error: Invalid field Country__c for SObject Holiday

What i am doing Mistake please anyone rectify the mistake

  • 1
    for(Holiday record: this should be for(Holiday__c record: . – Mr.Frodo Mar 17 '17 at 5:56
  • ok Thankyou@Mr.Frodo – Learning user Mar 17 '17 at 5:58
2

Try to use below code. Instead of Holiday you should use Holiday__c custom object

Set<String> markets = new Set<String>();
Map<string, Map<Date,Holiday__c>> holidays = new Map<string, Map<Date,Holiday__c>>();
for(String market: markets) {
   holidays.put(market, new Map<Date, Holiday__c>());
}
for(Holiday__c record: [SELECT Date__c, Country__c FROM Holiday__c WHERE Country__c = :markets]) {
   holidays.get(record.Country__c).put(record.Date__c, record);
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.