///////////////////////Start Of JS Helper////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// if (typeof (RES) == "undefined") { RES = { __namespace: true }; } RES.PortalHelper = { addCustomValidator: function (fieldName, fieldLabel, validationFunction, customErrorMessage) { if (typeof (Page_Validators) == 'undefined') return; // Create new validator $("#" + fieldName + "_label").parent().addClass("required"); var newValidator = document.createElement('span'); newValidator.style.display = "none"; newValidator.id = "RequiredFieldValidator" + fieldName; newValidator.controltovalidate = "casetypecode"; newValidator.errormessage = "" + customErrorMessage + ""; newValidator.validationGroup = ""; newValidator.initialvalue = ""; newValidator.evaluationfunction = function () { return validationFunction(); } // Add the new validator to the page validators array: Page_Validators.push(newValidator); // Wire-up the click event handler of the validation summary link $("a[href='#" + fieldName + "_label']").on("click", function () { scrollToAndFocus(fieldName + '_label', fieldName); }); }, addAttachmentTypeCustomValidator: function (fieldName, extensionsAllowed, customErrorMessage) { if (typeof (Page_Validators) == 'undefined') return; // Create new validator $("#" + fieldName + "_label").parent().addClass("required"); var newValidator = document.createElement('span'); newValidator.style.display = "none"; newValidator.id = "RequiredFieldValidator" + fieldName; newValidator.controltovalidate = "casetypecode"; newValidator.errormessage = "" + customErrorMessage + ""; newValidator.validationGroup = ""; newValidator.initialvalue = ""; newValidator.evaluationfunction = function () { return RES.PortalHelper.attachmentTypeCheck(fieldName, extensionsAllowed); } // Add the new validator to the page validators array: Page_Validators.push(newValidator); // Wire-up the click event handler of the validation summary link $("a[href='#" + fieldName + "_label']").on("click", function () { scrollToAndFocus(fieldName + '_label', fieldName); }); }, //eg. AddRequiredValidator("customerid", "Customer") addRequiredValidator: function (fieldName, fieldLabel) { if (typeof (Page_Validators) == 'undefined') return; // Create new validator $("#" + fieldName + "_label").parent().addClass("required"); var newValidator = document.createElement('span'); newValidator.style.display = "none"; newValidator.id = "RequiredFieldValidator" + fieldName; newValidator.controltovalidate = "casetypecode"; newValidator.errormessage = "" + fieldLabel + " is a mandatory field."; newValidator.validationGroup = ""; newValidator.initialvalue = ""; newValidator.evaluationfunction = function () { var value = $("#" + fieldName).val(); if (value == null || value == "") { return false; } else { return true; } }; // Add the new validator to the page validators array: Page_Validators.push(newValidator); // Wire-up the click event handler of the validation summary link $("a[href='#" + fieldName + "_label']").on("click", function () { scrollToAndFocus(fieldName + '_label', fieldName); }); }, //eg. RemoveRequiredValidator("customerid") removeRequiredValidator: function (fieldName) { $("#" + fieldName + "_label").parent().removeClass("required"); $.each(Page_Validators, function (index, validator) { if (validator !== undefined && validator !== null && validator.id !== undefined) { if (validator.id === "RequiredFieldValidator" + fieldName) { Page_Validators.splice(index, 1); } } }); }, // show hide fields on the form showHideField: function (fieldname, show) { if (show) { $("#" + fieldname).closest("tr").show(); } else { $("#" + fieldname).closest("tr").hide(); } }, //On save validation onSaveValidation: function (validationFunction) { if (typeof (webFormClientValidate) != 'undefined') { console.log("3"); var originalValidationFunction = webFormClientValidate; if (originalValidationFunction && typeof (originalValidationFunction) == "function") { console.log("4"); webFormClientValidate = function () { console.log("5"); originalValidationFunction.apply(this, arguments); console.log("6"); // do your custom validation here validationFunction(); }; } } }, //Empty lookup value clearLookupValue: function (fieldName) { $("#" + fieldName + "_name").attr("value", ""); $("#" + fieldName).attr("value", ""); $("#" + fieldName + "_entityname").attr("value", ""); //to clear quick view if any $("#" + fieldName).parent().find(".clearlookupfield").trigger('click'); }, //Empty field value clearFieldValue: function (fieldName) { $("#" + fieldName).attr("value", ""); }, // disable enable fields on the form enableDisableField: function (fieldname, enable) { if (enable) { $("#" + fieldname).prop('disabled', false); } else { $("#" + fieldname).prop('disabled', true); } }, // disable enable lookup on the form enableDisableLookupField: function (fieldname, enable) { if (enable) { $("#" + fieldname + "_name").parent().find(".input-group-btn").children().prop('disabled', false); } else { $("#" + fieldname + "_name").parent().find(".input-group-btn").children().prop('disabled', true); } }, //get field value getFieldValue: function (fieldName) { if (fieldName != null && fieldName !== "") { return $("#" + fieldName).val(); } else { return null; } }, //add refresh button to sharepoint document location grid addRefreshButtonToDocumentLocationGrid: function (gridElementId) { $("#" + gridElementId + " .grid-actions") .append('