Useful JavaScript commands for Microsoft CRM 2011 - Part 2: Xrm.Page.data.entity.attributes
Xrm.Page.data.entity.attributes
– provides methods to retrieve information and perform actions on attributes.
Command
|
Description
|
.addOnChange()
|
Sets a function to
be called when the attribute value is changed.
|
.fireOnChange()
|
Causes the OnChange
event to occur on the attribute so that any script associated to that event
can execute.
Example:
Xrm.Page.getAttribute("CRMFieldSchemaName").fireOnChange(); |
.getAttributeType()
|
Returns a string
value that represents the type of attribute.
|
.getFormat()
|
Returns a string
value that represents formatting options for the attribute.
|
.getInitialValue()
|
Returns the initial
value for Boolean or optionset attributes.
Attribute Types: Boolean,
optionset
|
.getIsDirty()
|
Returns a Boolean
value indicating if there are unsaved changes to the attribute value.
|
.getMax()
|
Returns a number
indicating the maximum allowed value for an attribute.
Attribute Types:
money, decimal, integer, double
|
Command
|
Description
|
.getMaxLength()
|
Returns a number
indicating the maximum length of a string or memo attribute.
Attribute Types: string,
memo
|
.getName()
|
Returns a string
representing the logical name of the attribute.
|
.getOption()
|
Returns an option
object with the name matching the argument passed to the method.
Attribute Types: optionset
|
.getOptions()
|
Returns an array of
option objects representing the valid options for an optionset attribute.
Attribute Types: optionset
|
.getSelectedOption()
|
Returns the option
object that is selected in an optionset attribute.
Attribute Types: optionset
Example:
Xrm.Page.getAttribute("Name
of Picklist").getSelectedOption().text;
Xrm.Page.getAttribute("Name
of Picklist").getSelectedOption().value;
|
.getText()
|
Returns a string
value of the text for the currently selected option for an optionset
attribute.
Attribute Types: optionset
|
.getParent()
|
Returns the entity
object that is the parent to the attribute.
|
.getPrecision()
|
Returns the number
of digits allowed to the right of the decimal point.
Attribute Types:
money, decimal, double, and integer
|
.getRequiredLevel()
|
Returns a string
value indicating whether a value for the attribute is required or
recommended.
|
.getSubmitMode()
|
Returns a string
indicating when data from the attribute will be submitted when the record is
saved.
|
.getUserPrivilege()
|
Returns an array of
privileges that contain Boolean values indicating if the user can create,
read or update data values for an attribute.
|
.getValue()
|
Retrieves the data
value for an attribute.
Example:
Xrm.Page.getAttribute(CRMFieldSchemaName).getValue();
|
.removeOnChange()
|
Removes a function
from the OnChange event hander for an attribute.
|
.setRequiredLevel()
|
Sets whether data is
required or recommended for the attribute before the record can be saved.
Example:
Xrm.Page.getAttribute(«CRMFieldName»).setRequiredLevel(«none»);
Xrm.Page.getAttribute(«CRMFieldName»).setRequiredLevel(«required»);
Xrm.Page.getAttribute(«CRMFieldName»).setRequiredLevel(«recommended»);
|
.setSubmitMode()
|
Sets whether data
from the attribute will be submitted when the record is saved.
Example:
Xrm.Page.getAttribute("Field
Name").setSubmitMode("always");
|
.setValue()
|
Sets the data value
for an attribute.
Example:
Xrm.Page.getAttribute("CRMFieldName").setValue(Value);
|
No comments:
Post a Comment