{Code Tip} Accessing fields in CRM header and footer using JavaScript

Sending
User Review
0 (0 votes)

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!

About the Author:

clip_image001

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