none
Error: Object doesn't support property or method setAttribute

    السؤال

  • HI,

    I'm new to programming in CRM and I'm trying to write a simple javascript that will take the first and last name of a lead and populate the company name field. Currently I only have the the OnChange event triggering on the last name. When I change the last name I receive the above error. Here is my code....

    function updateCompanyName()
    {
        var newCompanyName; 
        var firstName;
        var lastName;   
    
        firstName = Xrm.Page.getAttribute("firstname").getValue()
        lastName = Xrm.Page.getAttribute("lastname").getValue();
        newCompanyName = firstName + " " + lastName;  
      
        Xrm.Page.getAttribute("companyname").setAttribute(newCompanyName);
    
        alert(newCompanyName);
    }

    Thank you for the help!!

    Gary

    12/ربيع الثاني/1434 02:07 ص

الإجابات

  • That should work - maybe double check for any other typos - here is the final version - which I just tested on the OnChange event of the Lead form Last Name field.

    function updateCompanyName() {
        var newCompanyName;
        var firstName;
        var lastName;
    
        firstName = Xrm.Page.getAttribute("firstname").getValue()
        lastName = Xrm.Page.getAttribute("lastname").getValue();
        newCompanyName = firstName + " " + lastName;
    
        Xrm.Page.getAttribute("companyname").setValue(newCompanyName);
    
        alert(newCompanyName);
    }


    Jason Lattimer
    My Blog -  Follow me on Twitter -  LinkedIn

    • تم وضع علامة كإجابة بواسطة GaryMk 12/ربيع الثاني/1434 05:08 م
    12/ربيع الثاني/1434 04:59 م
    المشرف

جميع الردود