الأحد، 26 يناير 2014

CRM 2011 Validate required form using javascript


This code checks if form is valid for saving, by going over all required attributes and checking if it contains value.

function IsFormValidForSaving(){
var valid = true; Xrm.Page.data.entity.attributes.forEach(function (attribute, index) { if (attribute.getRequiredLevel() == "required") { if (attribute.getValue() == null) { if (valid) { var control = attribute.controls.get(0); alert(control.getLabel() + " Field is empty"); control.setFocus(); } valid = false; } } }); return valid;
}
http://dynamicslollipops.blogspot.com/2012/07/microsoft-dynamics-crm-2011-validate.html

هناك تعليق واحد: