Sunday 1 April 2012

Microsoft Dynamics CRM 2011 - JavaScript Development

There is a very handy JavaScript development cheat sheet available for Dynamics CRM 2011. It is by Daniel Cai, a Microsoft Dynamics CRM MVP. I always refer to this cheat sheet's PDF whenever I need help in the new CRM 2011 JavaScript model. Thanks to Daniel for a wonderful thought!

You can download this PDF from his blog:
http://danielcai.blogspot.com.au/2011/04/microsoft-dynamics-crm-2011-javascript.html

I am just displaying all the methods, in my blog, so that they are easy to search from any search engine.

Xrm.Page.context Methods
  • getAuthenticationHeader: Returns the encoded SOAP header for MSCRM 4.0 style Web service calls
  • getCurrentTheme: Returns the current user’s Outlook theme
  • getOrgLcid: Returns the LCID value for the base language of the organization
  • getOrgUniqueName: Returns the unique organizations name
  • getQueryStringParameters: Returns an array of key-value pairs representing the query strings
  • getServerUrl: Returns the base server URL
  • getUserId: Returns the current user’s SystemUser id
  • getUserLcid: Returns the LCID value representing the user’s preferred language
  • getUserRoles: Returns an array of GUID values of the security roles the user is associated with
  • isOutlookClient: Returns a Boolean value indicating if the user is using Outlook client
  • isOutlookOnline: Returns a Boolean value indicating if the user is connected to the server while using MSCRM for Outlook with Offline Access
  • prependOrgName: Prepends the organization name to the specified path
Xrm.Page.data.entity attribute Methods 
  • addOnChange: (Applicable: All) Sets a function to be called when the value is changed
  • fireOnChange: (Applicable: All) Causes the OnChange event to occur on the attribute
  • getAttributeType: (Applicable: All) Returns the type of attribute (string)
  • getFormat: (Applicable: All) Returns formatting options for the attribute (string)
  • getInitialValue: (Applicable: boolean, optionset) Returns the initial value for Boolean or optionset attributes
  • getIsDirty: (Applicable: All) Returns a Boolean value indicating if there are unsaved changes to the attribute value.
  • getMax: (Applicable: money, decimal, integer, double) Returns the maximum allowed value for an attribute (number)
  • getMaxLength: (Applicable: string, memo) Returns the maximum length of an attribute (number)
  • getMin: (Applicable: money, decimal, integer, double) Returns the minimum allowed value for an attribute (number)
  • getName: (Applicable: All) Returns the logical name of the attribute
  • getOption: (Applicable: optionset) Returns an option object by matching its name
  • getOptions: (Applicable: optionset) Returns an array of options for an optionset attribute
  • getParent: (Applicable: All) Returns the parent object to the attribute
  • getPrecision: (Applicable: money, decimal, double, integer) Returns the number of digits allowed after the decimal point
  • getRequiredLevel: (Applicable: All) Returns a string indicating whether the attribute is required or recommended
  • getSelectedOption: (Applicable: optionset) Returns the option selected in an optionset attribute.
  • getSubmitMode: (Applicable: All) Returns a string indicating if the attribute will be submitted when the record is saved
  • getText: (Applicable: optionset) Returns the selected option for an optionset attribute
  • getUserPrivilege: (Applicable: All) Returns an array of Boolean values indicating if the user can create/read/update an attribute's values
  • getValue: (Applicable: All) Retrieves the data value for an attribute
  • removeOnChange: (Applicable: All) Removes a function from the OnChange event handler
  • setRequiredLevel: (Applicable: All) Sets whether the attribute is required or recommended
  • setSubmitMode: (Applicable: All) Sets whether the attribute’s data will be submitted
  • setValue: (Applicable: All) Sets the data value for an attribute.
Form Event Handler Execution Context Reference
  • getContext: Returns the Xrm.Page.context object
  • getDepth: Returns a value indicating the order in which this handler is executed
  • getEventArgs: Returns an object with methods to manage the Save event
  • getEventSource: Returns a reference to the object that the event occurred on
  • getSharedVariable: Retrieves a variable set using setSharedVariable
  • setSharedVariable: Sets the value of a variable to be used by a hander after the current handler completes
Xrm.Page.ui control methods
  • addCustomView: (Lookup) Adds a new view for the lookup dialog
  • addOption: (Option Set) Adds an option to an Option set control
  • clearOptions: (Option Set) Clears all options for an Option Set control
  • getAttribute: (Standard, Lookup, Option Set) Returns the attribute that the control is bound to
  • getControlType: (All) Returns a value that categorizes controls
  • getData: (Silverlight Web resources) Returns the data query string parameter passed to a Silverlight Web resource
  • getDefaultView: (Lookup) Returns the ID value of the default lookup dialog view
  • getDisabled: (All) Returns a value indicating whether the control is disabled
  • getLabel: (All) Returns the label for the control
  • getName: (All) Returns the name assigned to the control.
  • getParent: (All) Returns a reference to the section object that contains the control.
  • getSrc: (IFrame, Web Resource) Returns the current URL being displayed in an IFRAME.
  • getInitialUrl: (IFrame) Returns the default URL of an IFrame control
  • getObject: (IFrame, Web resource) Returns the object in the form representing an IFrame or Web resource
  • getVisible: (All) Returns a value indicating if the control is visible
  • refresh: (SubGrid) Refreshes the data displayed in a Sub-Grid
  • removeOption: (Option Sets) Removes an option from an Option Set control
  • setData: (Silverlight Web resources) Sets the data query string parameter passed to a Silverlight Web resource.
  • setDefaultView: (Lookup) Sets the default view for the lookup dialog
  • setDisabled: (All except Web Resources) Sets a value indicating whether the control is disabled.
  • setFocus: (All) Sets the focus on the control.
  • setLabel: (All) Sets the label for the control.
  • setSrc: (IFrame and Web Resource) Sets the URL to be displayed in an IFrame.
  • setVisible: (All) Sets a value indicating if the control is visible
Xrm.Page.data.entity Methods
  • addOnSave: Sets a function to be called when the record is saved
  • getDataXml: Returns the xml string to be sent to the server when the record is saved
  • getEntityName: Returns the logical name of the entity for the record
  • getId: Returns GUID id value for the record
  • getIsDirty: Returns a Boolean value indicating if any fields in the form have been modified
  • removeOnSave: Removes a function from the OnSave event hander
  • save: Saves the record
Xrm.Page.ui Methods
  • close: Closes the form.
  • getCurrentControl: Returns the control that currently has focus
  • 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 refresh
Xrm.Page.ui.controls Collection Methods
  • forEach: Applies the action contained within a delegate function
  • get: Returns one or more controls
  • getLength: Returns the number of controls in the collection.
Xrm.Page.ui.navigation.items Collection Methods
  • forEach: Applies the action contained within a delegate function
  • get: Returns one or more navigation items
  • getLength: Returns the number of navigation items in the collection.
Xrm.Page.ui.formSelector members
  • items: (Collection) A collection of all accessible form items
  • getCurrentItem: (Method) Returns the form currently being shown.
Xrm.Page.ui.formSelector.items Collection Methods
  • forEach: Applies the action contained within a delegate function.
  • get: Returns one or more roleForms
  • getLength: Returns the number of roleForms in the collection.
Xrm.Page.ui.tabs Collection Methods
  • forEach: Applies the action contained within a delegate function
  • get: Returns one or more tabs
  • getLength: Returns the number of tabs in the collection.
Xrm.Page.data.entity.attributes Collection Methods
  • forEach: Applies the action contained within a delegate function
  • get: Returns one or more attributes
  • getLength: Returns the number of items in the collection.
Shortcut methods
  • Xrm.Page.getAttribute: Xrm.Page.data.entity.attributes.get
  • Xrm.Page.getControl: Xrm.Page.ui.controls.get
  • GetGlobalContext (Web Resources): Xrm.Page.context (within forms)

I hope this blog about 'Microsoft Dynamics CRM 2011 - JavaScript Development' was informative. Please feel free to leave your comments.

2 comments:

  1. Good One... Thanks for Sharing such a great information with us..

    ReplyDelete