Quantcast
Channel: CRM Development forum
Viewing all articles
Browse latest Browse all 8223

JScript: CRM 2011 problems after installing UR 16

$
0
0

Dear all,

after the installation of CRM 2011 UR 16 and some changes we are still facing some JScript problems with the account form. We changed an address text field into a dropdown field. On this dropdown field you can select different countries. After you choose a country additional information like the country code will be populated into other fields. Unfortunately we receive the following error message on the onload event:

Field: window

Event: onload

Error: <Message>Unable to set value of the property 'innerHTML': object is null or undefined</Message

The code:

function Form_onload()

{

if (Xrm.Page.context.getUserLcid() == 1031)

{

    var fieldName = "address1_primarycontactname";

    var defaultValue = Xrm.Page.getAttribute(fieldName).getValue();

    if(!defaultValue && Xrm.Page.ui.getFormType() == 1)

    {

        defaultValue = "D;Deutschland;Germany;+49";

        Xrm.Page.getAttribute(fieldName).setValue(defaultValue);

        address1_primarycontactname_onchange();

    }

        else if (!defaultValue && Xrm.Page.ui.getFormType() == 2)

    {

        defaultValue = "";

         Xrm.Page.getAttribute(fieldName).setValue(defaultValue);

    }

        var table = Xrm.Page.getAttribute(fieldName + "_d");

   var select = "<select req='0' id='" + fieldName + "' name='" + fieldName + "' defaultSelected='' tabindex='" + fieldName.tabIndex + "' >";

    var selectOptions;

    var defaultValueFound = false;

    var arrLand = "";

    var options = new Array(

    ";;;",

    "EG;Ägypten;Egypt;+20",

    "AL;Albanien;Albania;+355",

    "DZ;Algerien;Algeria;+213",

    ... etc.

    );

    for (index in options)

    {

       arrLand = options[index].split(";");

       select += "<option value='" + options[index] + "'";

       if (options[index] == defaultValue)

       {

         select += " SELECTED";

         defaultValueFound = true;

       }

       select += ">" + arrLand[1]+ "</option>";

    }

    if ((defaultValue != null) && (defaultValue.length > 0) && !defaultValueFound)

    {

       select += "<option value='" + defaultValue + "' SELECTED>" + defaultValue + "</option>";

    }

    select += "</select>";

    table.innerHTML = select;

    var dropdown_land = document.getElementById(fieldName);

    dropdown_land.setAttribute("onchange", function () { SaveDropDownSelection(dropdown_land, "address1_primarycontactname"); address1_primarycontactname_onchange(); });

}

}

function address1_primarycontactname_onchange()

{

    var arrSelected = Xrm.Page.getAttribute("address1_primarycontactname").getValue().split(";");

    var strLandKurz = arrSelected[0];

    var strLandLang = arrSelected[1];

    var strLandLangen = arrSelected[2];

    var strLandVorwahl = arrSelected[3];

    var strTelefon = Xrm.Page.getAttribute("telephone1").getValue();

    if(!strTelefon || strTelefon.length < 10 )

    {

        Xrm.Page.getAttribute("fax").setValue(strLandVorwahl);

        Xrm.Page.getAttribute("telephone1").setValue(strLandVorwahl);    

    }

    Xrm.Page.getAttribute("address1_telephone3").setValue(strLandKurz);

    Xrm.Page.getAttribute("address1_country").setValue(strLandLang);

    Xrm.Page.getAttribute("address1_telephone2").setValue(strLandLangen);

}

I hope somebody can help me

Thanks, Simon

    


Viewing all articles
Browse latest Browse all 8223

Trending Articles