MS CRM 4.0 Jscript Field Types
To access the properties and methods of the field objects within the crmForm, use the schema name of the entity attribute. For example, to access the Topic field in a Lead form, use the syntax crmForm.all.subject.
The following table shows the Properties that are available for all fields:
General Field Properties | Type | Values |
{field}.DataValue | Varies for each field type | Get/Set Property
Valid for all field types. Note that setting value in a script does not raise the OnChange event. You can use the FireOnChange field method to perform this function. |
{Field}.Disabled | Boolean | Get/Set Property
The field is displayed as read-only to the user. However it can be updated by a script. This field is submitted to the server when it is modified. Example var oField = crmForm.all.SOME_FIELD_ID; // Toggle the disbled state of the field oField.Disabled = !oField.Disabled; |
{Field}.RequiredLevel | Get property. Determines the level of requirement for the field. Valid values are as follows: 0 = No constraint (normal) 1 = Business recommended 2 = Business required Example var CRM_REQUIRED_LEVEL_NORMAL = 0; var CRM_REQUIRED_LEVEL_RECOMMENDED = 1; var CRM_REQUIRED_LEVEL_REQUIRED = 2; var oField = crmForm.all.SOME_FIELD_ID;
switch (oField.RequiredLevel) { case CRM_REQUIRED_LEVEL_NORMAL: alert("This field is not required or recommended"); break;
case CRM_REQUIRED_LEVEL_RECOMMENDED: alert("This field is business recommended"); break;
case CRM_REQUIRED_LEVEL_REQUIRED: alert("This field is required"); break; } | |
{Field}.IsDirty | Boolean | Get property. True if the field's value has changed. Example var oField = crmForm.all.SOME_FIELD_ID;
if (oField.IsDirty) { alert("The field's value has changed."); } else { alert("The field's value has not changed."); } |
{Field}.ForceSubmit | Boolean | Get/set property. Determines whether the value will be submitted to the server on save. All enabled fields will be submitted after they have been modified either through script or by user input.
Set this property to True for disabled or read-only fields and for fields that have not been modified if you want to submit them. |
The following methods are available on all fields
General Field Method | Description |
{Field}.SetFocus() | Sets the focus, changes tabs, and scrolls the window as necessary to show the specified field. Example
// Set focus to the field. crmForm.all.SOME_FIELD_ID.SetFocus(); |
{Field}.FireOnChange() | Programmatically raises the OnChange event for the specified field. Example
// Set focus to the field. crmForm.all.SOME_FIELD_ID.FireOnChange(); |
Comments