Wednesday, September 10, 2014

Validate a CRM field Data

//You can do it in both ways, onChange or onSave.






//For OnSave

//Keep it in the OnSave


function Validate(execObj)//Pass Execution Object from Form Editor



{

var optionSetValue=Xrm.Page.getAttribute("fieldName").getValue();

if(optionSetValue==330760000)



{

alert('Please Select value for field name');



execObj.getEventArgs().preventDefault();

}

}

//For Onchange

//Keep it in the OnChange


function Validate()



{

var optionSetValue=Xrm.Page.getAttribute("fieldName").getValue();

if(optionSetValue==330760000)



{

alert('Please Select value for field name');

Xrm.Page.getAttribute("fieldName").setValue(null);



}

}

 

No comments:

Post a Comment