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
JesseRCJesseRC 

Lead Triggers show null lead information

I have two lead triggers, Before Insert and After Insert. Both are showing null information for some fields. To test I am printing out lead information in the very beginning of Before Insert trigger and lead.Name always shows as Null. But I when open lead in UI the name is filled in correctly. Earlier today they were working just fine. The only changes I made were adding comment blocks for documentation. After that this issue started.

 

Any explanations? Could it be from updating trigger apiVersion from 16.0 to 19.0?

Best Answer chosen by Admin (Salesforce Developers) 
jkucerajkucera

I haven't used the name field much, but would assume it would be populated in both before & after triggers.

 

As a workaround, can you use first name + last name in the trigger & email?

All Answers

jkucerajkucera

It's hard to know without your code.  Please post your trigger & highlight the area's you thing are creating the problems.

JesseRCJesseRC

I don't mind posting code but there is alot so let me see if i can give a synopsis :

 

Lead Before Insert Trigger: Try to find duplicate lead and using coded in rules decide if original owner should get new lead. If no existing lead was found then use round robin to find Id of user to setas owner.

 

Lead After Insert Trigger: If ownerId is not admin user (lead has properly been assigned) send out notification email to Owner.

 

What i found that lead.Name was returning null in different areas both triggers and in email being sent out. But lead.FirstName and lead.LastName would work fine. This might make sense to me if it only happened in the Before Insert trigger. 

 

The only thing that changed from these triggers being able to use lead.Name working fine and not working was me entering comment blocks in the code and maybe the update of API from 16.0 to 19.0. 

jkucerajkucera

I haven't used the name field much, but would assume it would be populated in both before & after triggers.

 

As a workaround, can you use first name + last name in the trigger & email?

This was selected as the best answer
JesseRCJesseRC

That is what I ended up using.