Showing posts with label Web resource. Show all posts
Showing posts with label Web resource. Show all posts

Thursday, January 22, 2015

Disable HTML web resource control from CRM Form events

Call below function on CRM form event to access HTML web resource control by tag or Id



function DisableHTMLWebresouceControl()
{
//Get HTML web resource control
 var webRefCtrl = Xrm.Page.getControl('Your web resource ID from form').getObject();

 //web resource HTML document
 var htmlDoc=webRefCtrl.contentDocument;

 //get list of controls by tag name
 var ctrlList = htmlDoc.getElementsByTagName('select');

 //get list of controls by Id
 var ctrlById= doc.getElementById('textCtrl');

 //If web resource is not loaded yet, then call same function after some time.
  if(ctrlList[0]==null)
  {
     setTimeout(DisableHTMLWebresouceControl,1000)
     return;
  }
 
 // disable control in HTML web resource.
 ctrlList[0].disabled =true;
}