Hello. I am trying to change the visibility of fields on my form based upon the lookup value record field parameters. i.e., if a certain record is selected in a lookup field then based upon the fields values of that lookup record the fields are set to hide or display. Below is my code that i have called on onload of form and onchange of a lookup field.
if (crmForm.all.new_serviceid.DataValue != null) {
var parentCustomerID = document.getElementById("new_serviceid");
var lookupItems = parentCustomerID.items[0].values;
var level = lookupItems[2].value;
var count = lookupItems[3].value;
if ((level == "No") || (count == "No")) {
Xrm.Page.ui.controls.get("new_level").setVisible(false);
Xrm.Page.ui.controls.get("new_count").setVisible(false);
}
if (level == "Yes") {
Xrm.Page.ui.controls.get("new_level").setVisible(true);
}
if (count == "Yes") {
Xrm.Page.ui.controls.get("new_count").setVisible(true);
}
}
I am getting an error on this line when i tried to save the form : var lookupItems = parentCustomerID.items[0].values;(unable to get value of the property '0' : object is null or undefined). Please Help.Any help would be greatly appreciated