Rules Manager JavaScript API

Deploying the Rules Manager widget to a form will grant you access to a number of JavaScript functions for the Portal Connector widgets. These functions will allow you to find the widget by its CSS class in order to achieve a number of tasks such as setting the value of the widget, enabling or disabling the control, binding an event to a particular widget, or returning the widget as a DOM element. Please note that in order for this to work, you must have a Rules Manager deployed to the form.

Find Control (cssClass)

The Find Control function accepts the CSS Class of a widget as its sole parameter. This function will then return the specified widget as an object. This function is necessary for the usage of functions that accept the control object as a parameter.

findControl Example

In this example, you can see that returning the CSS Class of a CRM Text Field will return the text field as an object.

Control Type (control)

The Control Type function accepts a control object and will return the type of the control.

controlType Example

In this example, we have to make use of the findControl function in order to return the CRM Text Field as an object. Following that, you just have to call the controlType function in order to retrieve the type of control.

Set Control Value (control, value)

The Set Control Value function allows you to set the value of a control object. This function only works for the CRMTextField, CRMStatus, CRMPicklist, CRMLookup, CRMDateTimeField, CRMBoolean, and CRMRatingField widgets.

CRM Text Field

setControlValue Text Field

In this example, the value of a text box is set to a provided value.

CRM Status Field

setControlValue Status Field

The status field only accepts two values, Active and Inactive.

CRM Pick list

setControlValue Pick List

In this example, the widget is set to the gender field. The pick list can only be set to a value that already appears inside of it; in this case male and female.

CRM Look Up

setControlValue Look Up

The CRM Look Up widget can only be set to a value that exists within the widget much like the pick list.

CRM Date Time Field

setControlValue Date Time

This example shows that there is more than one way to enter a date and a time through the API.

CRM Yes/No or Boolean

setControlValue Yes No

Please note that the only applicable options for a CRM Yes/No widget are true and false.

CRM Rating Field

setControlValue Rating Field

Get Control Value (control)

The Get Control Value function will return the value of the specified control. This function will only work for the CRMTextField, CRMStatus, CRMPicklist, CRMLookup, CRMDateTimeField, CRMBoolean, and CRMRatingField widgets

getControlValue Example

Disable Control (control)

The Disable Control function will set the Enabled property of the widget to false, thus disabling the widget.

disableControl Example

Enable Control (control)

The Enable Control function will set the Enabled property of the widget to true, thus enabling the widget.

enableControl example