Skip to main content
Microsoft Dynamics CRM forum

Javascript in dynamics crm

editSubscribe (0) ShareShare
Posted on by
How to get account related information when loading the contact form, for example I want to get account related fax value when i enter the account name on contact form  . explain with the code
  • Verified answer
    Dengliang Li Profile Picture
    Dengliang Li Microsoft Employee on at
    Javascript in dynamics crm
    I added a Text Area field to the Contact form to display the account's fax.
    The code is as follows.
    function onload(executionContext){
      var formContext = executionContext.getFormContext();
      //Gets the value of the Account Lookup field.
      var account = formContext.getAttribute("parentcustomerid");
       //If the Account Lookup field is empty, exit and clear the Text Area field.
      //Get the ID of the account record in the account lookup field
      var accountId = account[0].id;
      //Retrieves the value of this account record.
      Xrm.WebApi.retrieveRecord("account", accountId, "?$select=name,fax").then(
        function success(result) {
            // Populate the Text Area field with the fax for this account record.
          formContext.getAttribute("cr8a7_textarea").setValue("Retrieved values: Name: " + + ", Fax: " + result.fax)
        function (error) {
            // handle error conditions
    If my answer was helpful, please click Like, and if it solved your problem, please mark it as verified to help other community members find more.
    If you have further questions, please feel free to contact me .
    Best Regards,
    Dengliang Li

Helpful resources

Quick Links

New Blog Features Released!

Check out the new community blog features for viewers and authors…

Setting Up Knowledge Sources for Copilot…

Look at how configuring a comprehensive knowledge base is crucial…

Demystifying Copilot with Georg Glantschnig…

Industry experts answer burning questions directly from our amazing Community…


Andre Arnaud de Calavon Profile Picture

Andre Arnaud de Cal... 283,080 Super User

Martin Dráb Profile Picture

Martin Dráb 222,601 Super User

nmaenpaa Profile Picture

nmaenpaa 101,138

Featured topics

Product updates

Dynamics 365 release plans