Many a times there is need to access CRM fields in javascript which are present in either header or the footer. Here are snippets to access fields for enable/disable, get/set and control visibility which exist in either header or footer of a CRM form.
Header Field Scripts:
//Set Enabled to True:
Xrm.Page.getControl(‘header_ fieldname’).setDisabled(false);
//Set Enabled to False:
Xrm.Page.getControl(‘header_ fieldname’).setDisabled(true);
//Set Visibility to False:
Xrm.Page.getControl(‘header_ fieldname’).setVisible(false);
//Set Visibility to True:
Xrm.Page.getControl(‘header _ fieldname’).setVisible(true);
//Get Attribute Value in Footer:
Xrm.Page.getControl(‘header _ fieldname’).getAttribute().getValue();
//Set Attribute Value in Footer:
Xrm.Page.getControl(‘header _fieldname’).getAttribute().setValue(VALUE);
Footer Field Scripts:
//Set Visibility to False:
Xrm.Page.getControl(‘footer_ fieldname’).setVisible(false);
//Set Visibility to True:
Xrm.Page.getControl(‘footer_ fieldname’).setVisible(true);
//Get Attribute Value in Footer:
Xrm.Page.getControl(‘footer_ fieldname’).getAttribute().getValue();
//Set Attribute Value in Footer:
Xrm.Page.getControl(‘footer_fieldname’).getAttribute().setValue(VALUE);
Hope it helps and Happy CRMing!
![]() |
Check this out |
About the Author:
Twitter: https://twitter.com/msdynamicsblog
LinkedIn: https://www.linkedin.com/in/deepesh-somani-00296932
Google Play Store:
https://play.google.com/store/apps/details?id=com.dynamicsofdynamicscrm.msdynamicsblog&hl=en
Hi,
We have added JavaScript where we need to hide Header Status Reason field on Case form through Javascript.
We have used below code
var statusReason_header = Xrm.Page.getControl(“header_statuscode”);
The above code is returning null reference in Interactive service hub. However the above piece of code is working in web client. We have placed Status Reason field on Case form Header.
Thanks
Hi Bipin,
On Interactive Service hub form you can directly use Xrm.Page.getControl(“statuscode”).
Regards,
Deepesh
[…] that I got a few hits for statuscode – but that it was prefaced with the value header_. I followed this up with some further research online, which confirmed that, if fields in the Header need to be referenced, then they should be prefaced […]
[…] that I got a few hits for statuscode – but that it was prefaced with the value header_. I followed this up with some further research online, which confirmed that, if fields in the Header need to be referenced, then they should be prefaced […]