MS CRM 2011 JavaScript Events Part 2

MS CRM 2011 Xrm Form Reference

Xrm.Page.context

Xrm.Page.context provides access to the context object. The context object provides methods to retrieve information specific to an organization, a user, or parameters that were passed to the form in a query string.


Xrm.Page.context provides access to the following functions:

  • getAuthenticationHeader: Deprecated. Returns the encoded SOAP header necessary to use Microsoft Dynamics CRM web service calls using JScript.
  • getCurrentTheme Returns a string representing the current Microsoft Office Outlook theme chosen by the user.
  • getOrgLcid: Returns the LCID value that represents the Microsoft Dynamics CRM Language Pack that is the base language for the organization.
  • getOrgUniqueName: Returns the unique text value of the organizations name.
  • getQueryStringParameters: Returns an array of key value pairs representing the query string arguments that were passed to the page.
  • getServerUrl: Returns the base server URL. When a user is working offline with Microsoft Dynamics CRM for Microsoft Office Outlook, the URL is to the local Microsoft Dynamics CRM Web services.
  • getUserId: Returns the GUID value of the SystemUser.id value for the current user.
  • getUserLcid: Returns the LCID value that represents the Microsoft Dynamics CRM Language Pack that is the user selected as their preferred language.
  • getUserRoles: Returns an array of strings representing the GUID values of each of the security roles that the user is associated with.
  • isOutlookClient: Returns a Boolean value indicating if the user is using Microsoft Dynamics CRM for Microsoft Office Outlook.
  • isOutlookOnline: Returns a Boolean value indicating whether the user is connected to the Microsoft Dynamics CRM server while using Microsoft Dynamics CRM for Microsoft Office Outlook with Offline Access. When this function returns false, the user is not connected to the server. The user is interacting with an instance of Microsoft Dynamics CRM running on the local computer.
  • prependOrgName: Prepends the organization name to the specified path.

 

 

Xrm.Page.ui

Xrm.Page.ui contains methods to retrieve information about the user interface as well as collections for several subcomponents of the form.

Methods


The following table lists the methods of Xrm.Page.ui.

Method Description
close Closes the form.
getCurrentControl Returns the control object that currently has focus on the form.
getFormType Indicates the form context for the record.
getViewPortHeight Returns the height of the viewport in pixels.
getViewPortWidth Returns the width of the viewport in pixels.
refreshRibbon Causes the ribbon to re-evaluate data that controls what is displayed in it.

 

 

Xrm.Page.data.entity

Xrm.Page.data.entity provides methods to retrieve information specific to the record displayed on the page, the save method, and a collection of all the attributes included in the form. Attribute data is limited to attributes represented by fields on the form.

Methods


The following table lists the methods of Xrm.Page.data.entity.

Method Description
addOnSave Sets a function to be called when the record is saved.
getDataXml Returns a string representing the xml that will be sent to the server when the record is saved.
getEntityName Returns a string representing the logical name of the entity for the record.
getId Returns a string representing the GUID id value for the record.
getIsDirty Returns a Boolean value that indicates if any fields in the form have been modified.
removeOnSave Removes a function from the OnSave event hander.
save Saves the record. This method has three possible parameters.

 

 

 

 

 

Xrm.Page.data.entity Attribute Methods

The attribute object provides methods to retrieve information and perform actions on attributes. It also contains a Controls Collection.

Examples shown here are in the Sample: SDK.AttributeSamples.js library.

Methods


The following table lists the methods of the attribute object.

Method Description
addOnChange Sets a function to be called when the attribute value is changed.See also removeOnChangeAttribute Types: All
fireOnChange Causes the OnChange event to occur on the attribute so that any script associated to that event can execute.Attribute Types: All
getAttributeType Returns a string value that represents the type of attribute.Attribute Types: All
getFormat Returns a string value that represents formatting options for the attribute.Attribute Types: All
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.Attribute Types: All
getMax Returns a number indicating the maximum allowed value for an attribute.Attribute Types: money, decimal, integer, double
getMaxLength Returns a number indicating the maximum length of a string or memo attribute.Attribute Types: string, memo
getMin Returns a number indicating the minimum allowed value for an attribute.Attribute Types: money, decimal, integer, double
getName Returns a string representing the logical name of the attribute.Attribute Types: All
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
getParent Returns the entity object that is the parent to the attribute.Attribute Types: All
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.See also setRequiredLevelAttribute Types: All
getSelectedOption Returns the option object that is selected in an optionset attribute.Attribute Types: optionset
getSubmitMode Returns a string indicating when data from the attribute will be submitted when the record is saved.See also setSubmitModeAttribute Types: All
getText Returns a string value of the text for the currently selected option for an optionset attribute.Attribute Types: optionset
getUserPrivilege Returns an array of privileges that contain Boolean values indicating if the user can create, read or update data values for an attribute.Attribute Types: All
getValue Retrieves the data value for an attribute.See also setValue.Attribute Types: All
removeOnChange Removes a function from the OnChange event hander for an attribute.See also addOnChangeAttribute Types: All
setRequiredLevel Sets whether data is required or recommended for the attribute before the record can be saved.See also getRequiredLevel.Attribute Types: All
setSubmitMode Sets whether data from the attribute will be submitted when the record is saved.See also getSubmitMode.Attribute Types: All
setValue Sets the data value for an attribute.See also getValue.Attribute Types: All

Cheers,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s