You need to sign in to do that
Don't have an account?
Lead Name Null on before insert trigger
Hello guys,
can anybody help me on this. I have created a lead trigger (before insert) and this trigger is basically needs to check whether the name inserted by the user already exists on either contact or lead object. However, when I try to get the "name" field (standard object), the field is always null. It just doesn't make any sense. I would really appreciate it if someone can help me on this.
Here's my code snippet:
trigger FindDuplicateLeads on Lead (before insert, before update)
{
string nameStr;
if(Trigger.isInsert)
{
for(integer x = 0; x < Trigger.new.size(); x++)
{
if(x == 0)
{
nameStr = '\''+ Trigger.new[x].Name +'\'';
//other codes here......
}
}
system.debug('nameStr debug:'+nameStr);
}
}
Hello,
I think base from my observation the name field is always null even if you set the trigger either before or after insert. So with that, the solution I found is just get the stardard fields LastName and FirstName instead. You just have to concatenate them. Don't ask me why the name field is null though, because I don't know the answer as well.
Cheers