CRM 2011: Object [object Array] does not have a getValue method

advertisements

i want to access another object in my current function. i have a option set on my form and on change of option set it should check the date value

This is what i have tried -

document.EntityScript.AssessmentStatus_OnChange = function (context) {
 if (FormScripts.FormUtilities.GetOptionSetValue("assessmentstatusoptioncode") == 803870001) {
    var AssessmentDate = Xrm.Page.getAttribute("assessmentdate");
    FormScripts.FormUtilities.ValidateDateField(AssessmentDate, false, "Assessment date cannot be future for a completed assesment.");
 }

ValidateDateField: function (Obj, allowFuture, errMsg) {
    var isValidField = true;
    if (!eval(allowFuture)) {
        var assDate = this.ReadTextFieldValue(Obj);
        if (assDate.length > 0) {
            var oToday = new Date();
            var AssessmentDate = Date.parse(assDate);
            if (AssessmentDate > oToday) {
                alert(errMsg);
                obj.setValue(null);
                Xrm.Page.getControl(Obj.getName()).setFocus();
                isValidField = false;
            }
        }
    }
    return isValidField;
}

 ReadTextFieldValue: function (fieldName) {
    var fieldValue = "";
    if (fieldName.getValue() != null) {
        fieldValue = Xrm.Page.getAttribute(fieldName).getValue().toString();
    }

    return fieldValue;
}

But with i am getting the follwing error :

Object [object Array] has no method 'getValue'

please help me resolve this.


Your ReadTextFieldValue looks wrong: Your fieldName being passed in is an attribute, not a field name. I think you want it like this

ReadTextFieldValue: function (fieldName) {
    var fieldValue = "";
    if (fieldName.getValue() != null) {
        fieldValue = fieldName.getValue();
    }

    return fieldValue;
}