You need to sign in to do that
Don't have an account?
Dbjensen
Traversing lookup field
Hello - I have a for loop that adds a string and Id to a map. This field in the map Field_Agent__r. is a lookup field. The Id keeps coming back as null.
Any idea why? I verified that the Field_Agent__c and User__c is populated.
Map<String, Id> fieldAgentUserIdMap = new Map<String, Id>(); //Hold Field Agent Username
for(Lead newLead : newlyCreateLeads){
fieldAgentUserIdMap.put(newLead.Field_Agent_SOB__c, newLead.Field_Agent__r.User__c);
}
System.debug('Field agent in map '+fieldAgentUserIdMap);
DEBUG|Field agent in map {1234567=null}
Any idea why? I verified that the Field_Agent__c and User__c is populated.
Map<String, Id> fieldAgentUserIdMap = new Map<String, Id>(); //Hold Field Agent Username
for(Lead newLead : newlyCreateLeads){
fieldAgentUserIdMap.put(newLead.Field_Agent_SOB__c, newLead.Field_Agent__r.User__c);
}
System.debug('Field agent in map '+fieldAgentUserIdMap);
DEBUG|Field agent in map {1234567=null}
Hi,
Please use below code to solve your issue and kindly mark as best answer.
All Answers
Directly you can't able to refer the related fields in the trigger.new context variable.
If this, helps, Please mark it as best answer.
Thanks!!
Hi,
Please use below code to solve your issue and kindly mark as best answer.