Wednesday 19 October 2016

Access fields in Header and Footer using JavaScript

Hi,

Most of times we get a requirement to access fields on Header and Footer using JavaScript.
There is a little difference in the schema to access them. That is we just need header/footer as a prefix to the field name. Below are the some of the examples.

Accessing Header Fields
//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("anything");

Accessing Footer Fields
//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("anything");


Hope this helps.

--
Happy CRM'ing

Gopinath

No comments:

Post a Comment