Microsoft Dynamics CRM 2015 – Javascript API - Controls

Prvá časť zo série Microsoft Dynamics CRM – Javascript API zaoberajúca sa prácou s kontrolkami resp. vlastnosťami entít – in english for search engines.

The CRM javascript API for manipulation with the controls is represented by namespace called Xrm.Page. The control object provides methods to change the presentation or behavior of a control and identify the corresponding attribute. You can access controls using the following collections: Xrm.Page.ui.controls, but the most usefull shortcut method to access the specific control/attribute is Xrm.Page.getControl(‘attributeName’) method. Under the selected control, you can use folowing methods (we are specifiing only most common/usefull methods; full specification you can find on msdn network):

1. Disabled - Enable or disable the control:


2. Attribute - Returns the particular attribute value – usefull for lookup attribute :


3. Label - Get or change the label for a control using the getLabel and setLabel methods.


4. Notification - Use setNotification to display a notification about the control and clearNotification to remove it. Display a message near the control to indicate that data isn’t valid. When this method is used on Microsoft Dynamics CRM for tablets a red "X" icon appears next to the control. Tapping on the icon will display the message.

Xrm.Page.getControl('attributeName').setNotification(message, messageId)

5. OptionSet - Use the addOption, clearOptions, and removeOption methods to manipulate options available for OptionSet controls.

Xrm.Page.getControl('attributeName').addOption(option, [index])

Option is little object with text and value properties.


6. Refresh - Refreshes the data displayed in a subgrid.


7. Focus - Sets the focus on the control.


8. Time - specify whether a date control should show the time portion of the date.


9. Visible - Determine which controls are visible and show or hide them using the getVisible and setVisible methods.


10. IFrame - Use these methods to interact with web resource and IFRAME controls.


Returns the value of the data query string parameter passed to a Silverlight web resource.


Sets the value of the data query string parameter passed to a Silverlight web resource.


Sets the URL to be displayed in an IFRAME or web resource.

Little tip to the end: If you want to manipulate with control in the header of the form, specify prefix “header_” before property name. Example : Xrm.Page.getControl(‘header_attributeName’).

Comments are closed