Skip to main content
Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Answered

Auto-populating data on Lead form

(1) ShareShare
ReportReport
Posted on by 6
My question/problem is around how data is populated on the Lead form. We utilize an field called "Existing Contact" in the BPF which is linked to the Parent Contact for Lead field (see attached screenshot). We also use a field called "Existing Account" which is tied to the Parent Account for Lead field. When we enter in a contact in the Existing Contact field, it populates the First Name, Last Name, Business Phone, Mobile Phone and Email fields. However, when we enter an account in the Existing Account field, it ONLY populate the Company Name. It doesn't pull in the phone, website, address, etc.
 
My question is what is used to pull this data in? I was thinking it was a Java Script that when the lookup was filled it would populate the other fields. I do not have any workflows that run when those fields are filled in to populate the data. Any thoughts?
Categories:
  • Verified answer
    Muhammad Shahzad Shafique Profile Picture
    843 Most Valuable Professional on at
    Auto-populating data on Lead form
    The automatic population of fields (e.g., name, phone, email) when selecting Existing Contact is handled by out-of-the-box (OOB) JavaScript in the Lead form.
    For Existing Account, only Company Name is populated by default. Dynamics 365 does not natively auto-populate other fields like phone, website, or address from the selected account.
    Conclusion:
    Yes, JavaScript (likely on the Lead form) is responsible for populating the contact-related fields. To replicate similar behavior for the account, you need to implement a custom JavaScript function triggered on the Existing Account field's OnChange event to fetch and populate the desired account fields.


     
  • Verified answer
    Hamza H Profile Picture
    320 on at
    Auto-populating data on Lead form
    function populateAccountDetails(executionContext) {
        var formContext = executionContext.getFormContext();
        var accountLookup = formContext.getAttribute("parentaccountid").getValue();
    
        if (accountLookup && accountLookup.length > 0) {
            var accountId = accountLookup[0].id.replace("{", "").replace("}", "");
    
            Xrm.WebApi.retrieveRecord("account", accountId, "?$select=telephone1,websiteurl,address1_line1,address1_city,address1_stateorprovince,address1_postalcode")
                .then(function(result) {
                    formContext.getAttribute("telephone1").setValue(result.telephone1);
                    formContext.getAttribute("websiteurl").setValue(result.websiteurl);
                    formContext.getAttribute("address1_line1").setValue(result.address1_line1);
                    formContext.getAttribute("address1_city").setValue(result.address1_city);
                    formContext.getAttribute("address1_stateorprovince").setValue(result.address1_stateorprovince);
                    formContext.getAttribute("address1_postalcode").setValue(result.address1_postalcode);
                },
                function(error) {
                    console.log("Error retrieving account: " + error.message);
                });
        }
    }
    
     
  • Suggested answer
    Inogic Profile Picture
    599 on at
    Auto-populating data on Lead form
    Hi,
     
    The values populating when selecting an Account or Contact in the Existing Account or Existing Contact fields is out-of-the-box (OOB) behavior.
    • If you select an Account in the Existing Account field, the Company Name will be populated.
    • If you select a Contact in the Existing Contact field, the Last Name, First Name, Job Title, Business Phone, Mobile Phone, and Email associated with that Contact will be populated.
    However, if you have already entered different values in those fields, they will not be overwritten.
     
    Hope this helps.
     
    Thanks!
    Inogic

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Ramesh Kumar – Community Spotlight

We are honored to recognize Ramesh Kumar as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Holly Huffman Profile Picture

Holly Huffman 103

#2
Muhammad Shahzad Shafique Profile Picture

Muhammad Shahzad Sh... 96 Most Valuable Professional

#3
Gerardo Rentería García Profile Picture

Gerardo Rentería Ga... 51 Most Valuable Professional

Product updates

Dynamics 365 release plans