I have the following script that keeps error out when it trys to set the name field to null. The error I get is "Unable to get property 'setValue' of undefined or null reference" I have made sure that the field is spelled correctly and exists on the form. When stepping through the logic in debugger, it does pick up the text field of Name just fine. Issue is when I try to set it to null that it doesn't like it. Please help, thank you.
function onSaveSetName ()
{
var name = Xrm.Page.getAttribute("nhs_description").getValue();
var measurement = Xrm.Page.getAttribute("nhs_measurement").getText();
var separator = ' - ';
var contractliinetitle = Xrm.Page.getAttribute("nhs_contractdetailtype").getValue();
var contractdetailtype = Xrm.Page.getAttribute("nhs_resultscontractdetailtype").getSelectedOption().text;
var month = Xrm.Page.getAttribute("nhs_resultseffectivemonth").getSelectedOption().text;
var quarter = Xrm.Page.getAttribute("nhs_resulteffectivequarter").getSelectedOption().text;
var year = Xrm.Page.getAttribute("nhs_resulteffectiveyear").getSelectedOption().text;
var dateFieldValue = new Date(enddate);
var year = dateFieldValue.getFullYear() + "";
var month = (dateFieldValue.getMonth() + 1) + "";
var day = dateFieldValue.getDate() + "";
var enddate = month + "/" + day + "/" + year;
/*Contract Detail Type: Guarantee = 127130000
Measurement: Monthly = 127130000, Quarterly = 100000000, Annually = 100000001, By Audit Request Only = 100000002*/
if (contractdetailtype == "Guarantee" && measurement == "Monthly" && contractliinetitle !=null)
{
Xrm.Page.getAttribute("name").setValue(null);
Xrm.Page.getAttribute("name").setValue(contractliinetitle + separator + month + separator + quarter + year);
Xrm.Page.ui.controls.get("name").setDisabled (true);
}
else if (measurement != "Guarantee")
{
Xrm.Page.ui.controls.get("nhs_description").setDisabled (false);
}
}
*This post is locked for comments