dynamics-crmdynamics-crm-2016xrm

how to get field validation state in crm


I'm using crm 2016, after the user click a customize button, all fields on the form are locked. My problem is that the user insert wrong data to a field and by mistake closes the form (all fields) so the field with wrong data (letters instead digits for example) is with a validation notification but cannot be edited no more.

I need a way to find if that specific field validation rule is false (and then I'll stop the form from being locked until that validation notification is gone). My question is according to what rule can I find a field with validation error? or if there is another way to do it?


Solution

  • You are locking the form fields irrespective of validation, that’s the problem.

    Do a success save check, then lock if it passes validation in success callback. If not return false, this will avoid locking fields when validation fails.

    Xrm.Page.data.save().then(function(){console.log('Success')},function(){console.log('Error')});