You need to sign in to do that
Don't have an account?
Trigger issue: Initial term of field expression must be a concrete SObject
Hello, I'm very new to triggers and need some assistance with some code. When I try to save the following trigger, I receive the error "Error: Compile Error: Initial term of field expression must be a concrete SObject: MAP<Id,Lead> at line 20 column 75 ". Offending expression in bold red. How do I refer to the Assigned_Date__c field so that the code recognizes it? I've tried l.Assigned_Date__c but then I get a variable doesn't exist error. I've also tried setting up a new variable but I can't pass the Lead's value into the variable. Any help is appreciated.
trigger LeadInsertUpdate on Lead(after insert, after update){
Set<Id> LeadSetOfIds = new Set<Id>();
BusinessHours bh = [SELECT Id FROM BusinessHours WHERE IsDefault=true];
DateTime No_Contact_Reassign_Date;
//then iterate through your Leads
for(Lead l : trigger.new){
if(l.Id != null){
LeadSetOfIds.add(l.Id);
}
}
Map<Id,Lead> LeadMap = new Map<Id,Lead>([select Id, Assigned_Date__c, No_Contact_Reassign_Date__c, No_Conversion_Reassign_Date__c from Lead
where Id in : LeadSetOfIds]);
if(LeadMap.get(LeadMap.Assigned__Date__c)!=null)
// {No_Contact_Reassign_Date = BusinessHours.addGmt(bh.Id, LeadMap.get(LeadMap.Assigned__Date__c), 8 * 60 * 60 * 1000L);}
// need to figure out how to get assigned date here..
}
The map you have defined 'LeadMap', is a set of <key, value> pairs where the key is an ID and the value is a Lead. Your code "LeadMap.get(LeadMap.Assigned__Date__c)" is asking to get the value of an item with the key 'LeadMap.Assigned__Date__c'.
Try something like
Hope this helps!
Daniel Reid
Contact us - We can help!
Salesforce Superheroes
------------------------------
help@salesforcesuperheroes.com
www.salesforcesuperheroes.com
1-888-407-9578 x102
All Answers
The map you have defined 'LeadMap', is a set of <key, value> pairs where the key is an ID and the value is a Lead. Your code "LeadMap.get(LeadMap.Assigned__Date__c)" is asking to get the value of an item with the key 'LeadMap.Assigned__Date__c'.
Try something like
Hope this helps!
Daniel Reid
Contact us - We can help!
Salesforce Superheroes
------------------------------
help@salesforcesuperheroes.com
www.salesforcesuperheroes.com
1-888-407-9578 x102
A map always contains <Key, Value> pair, so whenever we want value from a map we have to retrieve value on basis of its key values. In your case you can retrieve or loop through map as follows :
Try this, it will work for you and if it is mark the solution as appropriate.
Thanks
Vikash Goyal
Thanks all! I ended up going to a colleague and she helped me to get a list of leads rather than a list of lead ids but these solutions would have helped also. Thanks for the explanations.