+ Start a Discussion
kibitzerkibitzer 

Perplexing lead Lead status after conversion

Ok, this one is perplexing and I'm hoping someone has some ideas....

 

I'm using an After Update trigger on Lead to check for lead conversion. At that point I want to look at the lead status. I was expecting the lead status to match the "conversion status" specified on the lead conversion page by the user. But at that point it in time (during the after update trigger) it still contains the original status value.

 

There is no other trigger being raised on the lead (that I can see in the debug logs) - yet when I do a report later on converted leads, the lead status does match the one specified on the lead conversion page.

 

So this leads me to wonder:

1. Is the lead status field actually being updated?

2. If so, when is it being updated, and what can I trigger on to look at it?

 

Any ideas?

Pradeep_NavatarPradeep_Navatar

On converting  the lead account,opportunity and contact  are created. Find below a sample trigger code. This trigger updates account field after converting the lead :

                                                                                               
    trigger trigMapFields on Lead (before update)
    {
    for(Lead lead:System.Trigger.new)
    {
        if (lead.IsConverted)
        {
            // Assign the value from the Account "MasterContact"  lookup field to the ContactID"
            system.debug('<!---------Convert Leads 222 --------->');
            Account acc = [SELECT Id,MasterContact__c FROM Account WHERE Account.Id = :lead.ConvertedAccountId];
            Contact con = [SELECT Id FROM Contact WHERE Contact.Id = :lead.ConvertedContactId];
            acc.MasterContact__c = con.id;
            update acc;
            system.debug('<!---------Check Account Fields 111--------->'  + acc.MasterContact__c);
        }
    }
    }

 

Hope this helps.

kibitzerkibitzer

No - sorry, that doesn't really address my question.

 

I'm familiar with lead conversion code - mine looks similar. My point is that the Lead.Status field during the after-update trigger match the conversion status set by the user before the conversion begins.

 

Also, in the particular case I'm testing, the user is not creating an opportunity during the conversion.

 

Dan