Access a html webresource control from javascript webresource
If you have any doubt in the post please post comments. I will try to solve your problem.
To add html control in the CRM form. we have to create new html web resource and insert the html web resource in the form.
Some times we need to access html control from outside Java-script web resource.
Syntax:
var customHtml = Xrm.Page.ui.controls.get("WebResource Name");
if(customHtml!=null || customHtml!='')
var destination = customHtml.getObject().contentWindow.document;
if(destination!=null || destination!='')
var customControl = destination.getElementById("control name");
Example:
Disabled the html control from javascript webresource
var customHtml = Xrm.Page.ui.controls.get("WebResource_CarrierLookup");
if(customHtml!=null || customHtml!='')
var destination = customHtml.getObject().contentWindow.document;
if(destination!=null || destination!='')
var customControl = destination.getElementById("btnLookup");
if(customControl!=null || customControl!='')
customControl.disabled=false;
If you have any doubt in the post please post comments. I will try to solve your problem.
To add html control in the CRM form. we have to create new html web resource and insert the html web resource in the form.
Some times we need to access html control from outside Java-script web resource.
Syntax:
var customHtml = Xrm.Page.ui.controls.get("WebResource Name");
if(customHtml!=null || customHtml!='')
var destination = customHtml.getObject().contentWindow.document;
if(destination!=null || destination!='')
var customControl = destination.getElementById("control name");
Example:
Disabled the html control from javascript webresource
var customHtml = Xrm.Page.ui.controls.get("WebResource_CarrierLookup");
if(customHtml!=null || customHtml!='')
var destination = customHtml.getObject().contentWindow.document;
if(destination!=null || destination!='')
var customControl = destination.getElementById("btnLookup");
if(customControl!=null || customControl!='')
customControl.disabled=false;
Some times we need to access html control from outside Java-script web resource.psd to html5
ReplyDeleteHi I am not able to access a button in html web resource (placed on a section in form) from javascript on form
ReplyDeletei have tried using the above code. no help.
DeleteMay i know your requirement and what is your problem
DeleteI am trying to Hide Form Ribbon button(i.e Deactivate) based security role for that i have wrote JS script for getting role
ReplyDeletewhen i try to get the ribbon button ID, It is giving Null
1) btnHide = document.getElementById("account|NoRelationship|Form|Mscrm.Form.account.SaveAndClose" + "_d");
2) var objValue = Xrm.Page.getAttribute("account|NoRelationship|Form|Mscrm.Form.account.SaveAndClose");
3) btnHide1 = window.top.document.getElementById("account|NoRelationship|Form|crm.Form.account.SaveAndClose");
Above all are giving Null value.
any idea