Form Properties

banner art

[Applies to: Microsoft Dynamics CRM 4.0]

Find the latest SDK documentation: CRM 2015 SDK

Form properties are accessed with the following syntax:

crmForm.propertyname

The following table shows the available form properties.

Property name Type Values
IsDirty Boolean True if any fields in the form have been modified.
FormType Integer A read-only property that returns information about the form type. See Remarks.

Valid values:

Undefined Form Type = 0

Create Form = 1

Update Form = 2

Read Only Form = 3

Disabled Form = 4

Quick Create Form = 5

Bulk Edit Form = 6

ObjectId * String A read-only property that contains the ID of the entity instance displayed in the form. If the form is a create form, the value is null.
ObjectTypeCode * String A read-only property that contains the entity type code of the entity instance displayed in the form. See Entity Type Codes
ObjectTypeName * String A read-only property that contains the entity name of the entity instance displayed in the form. For system entity names, see the EntityName enumeration..
all.{field name}   Collection used to reference a particular field or IFRAME on the form.

Remarks

Important: You should always consider the form type in your code. In particular, consider how your code will work in the Bulk edit forms.

The Bulk edit form will not include existing data for each record that will be updated. If your business logic depends on specific data for each record to be present in the form, you may want to set specific conditions on which fields you will allow to be updated using the Bulk edit form.

Note   The quick create form is no longer launched by Microsoft Dynamics CRM.

The following table contains additional information about form types.

Form Form type value Description
Undefined 0 For internal use only.
Create 1 This is the main form for an entity, displayed with blank values when creating an entity instance.
Update 2 This is the main form for an entity, displayed with the current values for the entity instance being updated.
Read only 3 This is the main form for an entity, displayed with the current values for the entity instance. All fields are disabled. This is used when the user does not have privileges or access rights to edit the entity instance.
Disabled 4 This is the main form for an entity, displayed with the current values for the entity instance. All fields are disabled. This is used when the entity instance is in the Inactive state.
Quick create 5 This form contains the minimum fields needed to create an entity instance and any Business Recommended fields. It is not used by in the Microsoft Dynamics CRM application.
Bulk edit 6 This form is used for editing multiple instances at a time. This form is shown when users select multiple records in a grid and select edit from the More Actions menu.

Example

The following code shows how to access the form properties such as form type.

var CRM_FORM_TYPE_CREATE = 1;
var CRM_FORM_TYPE_UPDATE = 2;
var CRM_ENTITY_ACCOUNT = 1;
var CRM_ENTITY_CONTACT = 2;

// Test the FormType and ObjectId properties.
switch (crmForm.FormType)
{
   case CRM_FORM_TYPE_CREATE:
      alert("This is a create form.");
      break;

   case CRM_FORM_TYPE_UPDATE:
      alert("This is an update form, the ID is " + crmForm.ObjectId + ".");
      break;
}


// Test the ObjectTypeCode property.
switch (crmForm.ObjectTypeCode)
{
   case CRM_ENTITY_ACCOUNT:
      alert("This is an Account form.");
      break;

   case CRM_ENTITY_CONTACT:
      alert("This is a Contact form.");
      break;
}

See Also

Concepts

Other Resources

© 2010 Microsoft Corporation. All rights reserved.