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
Alex23Alex23 

How do I take a field from Lead and transferring to Account

How do I take a field from a lead and transfer it to the Account  like the phone # or description does?
Thank you

 Alex

C.

Ispita_NavatarIspita_Navatar

You can make use of a simple for this.

 

Find below a sample trigger code :

 

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);

        }

    }

}

 

This trigger would enable you to fill the custom field of an account with values taken over from lead record

 

Did this answer your question? if so, please mark it solved.

Alex23Alex23

 So I would have to create a trigger for this to have a relation from lead to account?

 thank you

Alex

Chavez  

SherriASherriA

I just use the built in lead mapping.  

 

Setup - App Setup - Customize - Lead - Lead Fields.  There's a button in the custom fields section to map lead fields which allows you to carry the information from your custom lead field to an existing field on the account record when the lead is converted.  

Alex23Alex23

 Thanks that helped my first problem!!! But  In the Lead I created it as an Object with information and when Convert it to an Account the object is in the account but the information does not transfer  that's the part I am stuck on. Thank you for helping I am trying to learn from this as well