Friday, 9 June 2017

Mobile compatible development - disable all fields using JS - Microsoft Dynamics CRM - MoCA_Tip#3


Hello All,

Lets go though a quick tip on best practice around disabling all fields using JavaScript in MoCA.

Issue:
In traditional CRM JS development, we tend to use  getDisabled function to identify whether a control is disabled or not and setDisabled to enable or disable a field.

But in MoCA there are some controls which do not expose the above functions which result in JS error(not defined or not found).

Fix:
Before calling the function validate whether the function exist or not  and then call the same. By this way we can avoid unnecessary chaos in our JS.

Code Snippet:

if (control && control.getDisabled && !control.getDisabled()) {
   control.setDisabled(true);
}


Refer this blog for MoCA compatible disable all fields script

Don't forget to go through previous tips if you have missed,
  1. Form Selector and its usage

No comments:

Post a Comment

AddToAny