Edit

Columns in model-driven apps (Client API reference)

Columns contain data in the model-driven apps form or grids. Use the formContext.data.entity.attributes collection or the formContext.getAttribute shortcut method to access a collection of columns. For more information about collections, see Collections (Client API reference).

To access a column within the collection, pass either the name (string) or the index value (number) of the column as an argument to the method. For example: formContext.getAttribute(arg). If you don't specify an argument, the method returns a collection of all attributes on the form.

Columns are categorized by type. Use the getAttributeType method to determine the type of the column. Certain column methods are only available for specific types of columns.

This article provides information about the methods available for each column type.

All column types

The controls property provides a collection of controls associated with the column.

The following methods are available for all column types:

Method Description
addOnChange Adds a function to run when the column's OnChange event occurs.
fireOnChange Triggers the column's OnChange event.
getAttributeType Returns the column's type.
getFormat Returns the column's format.
getIsDirty Returns whether the column has unsaved changes.
getName Returns the column's logical name.
getParent Returns the parent formContext.data.entity object.
getRequiredLevel Returns whether a column value is required or recommended.
getSubmitMode Returns when the column's data is submitted on save.
getUserPrivilege Returns the user's privileges to create, read, or update the column's value.
getValue Returns the column's data value.
isValid Returns whether the column's value is valid.
removeOnChange Removes a function from the column's OnChange event handlers.
setIsValid Sets the column's validity and an error message.
setRequiredLevel Sets whether a column value is required or recommended before saving.
setSubmitMode Sets whether the column's data is submitted on save.
setValue Sets the column's data value.

Boolean column type

In addition to the methods available for all column types, the boolean column type provides the following method:

Method Description
getInitialValue Returns the column's value when the form opened.

Lookup column type

In addition to the methods available for all column types, the lookup column type provides the following method:

Method Description
getIsPartyList Returns whether the lookup allows multiple records as a party list lookup.

Choices and choice column types

In addition to the methods available for all column types, the choices and choice column types provide the following methods:

Method Description
getInitialValue Returns the column's value when the form opened.
getOption Returns the option matching a specified label or value.
getOptions Returns the column's valid options.
getSelectedOption Returns the selected option or options.
getText Returns the text of the selected option or options.

Number column type (decimal, double, integer, money)

The following methods are available only for the decimal, double, and integer columns:

Method Description
getMax Returns the column's maximum allowed value.
getMin Returns the column's minimum allowed value.
getPrecision Returns the number of digits allowed after the decimal point.
setPrecision Sets the number of digits allowed after the decimal point.

String column type

In addition to the methods available for all column types as explained earlier, the following method is available only for the string column:

Method Description
getMaxLength Returns the column's maximum string length.

Understand Xrm object model
Controls (Client API reference)