April 8, 2013

Disable CRM 2011 Form Assistant for selected fields

the Form Assistant is a useful feature that allows to populate some lookup fields by providing a list on the right side of the form.



It's possible to disable completely the Form Assistant, but there is a way to disable the functionality only for some fields of the form?

To achieve this result we need to manipulate the DOM with JavaScript, in this example we remove the assistant for the fields Contract (contractid) and Contract Line (contractdetailid)
function DisableAssistantFields() {
   var fields = new Array("contractid", "contractdetailid");
   var selector = document.getElementById("ContextSelect");
   
   if (selector != null) {
      for (var i in fields) {
         var field = document.getElementById(fields[i] + "_context");
         if (field != null) {
            field.parentNode.removeChild(field);
         }
      }
      selector.onchange();
   }
}

0 comments:

Post a Comment