CRM 2013 New Client API Methods

Posted by on September 23, 2013  |  commentsComments (4)

With CRM 2013, Microsoft is providing some exciting new methods we can use with the JavaScript SDK on the entity forms.  Some highlights are an easier way to set the form dirty, custom lookup filters, and a supported way to display form notifications as well as field specific notifications.  See below for a full comprehensive list with details.


  • Xrm.Page.context.client.getClient()
    • Returns “Outlook”, “Web”, or “Mobile”
  • Xrm.Page.context.client.getClientState()
    • Returns “Online” or “Offline”
    • Xrm.Page.context.isOutlookOnline and isOutlookClient are now deprecated


    • Asynchronously refresh data on form without reloading the page
    • Can pass in a callback to execute on error or success
    • Asynchronously save the form
    • Can pass in a callback to execute on error or success
    • Returns a boolean telling whether the form can be saved or not
    • Sets the form as dirty


    • Returns a string value of the primary attribute for the entity


  • Xrm.Page.ui.setFormNotification()
    • Takes in a string value to set a form notification with the passed in string
    • Pass in “ERROR”, “INFORMATION” or “WARNING” to dictate the type of notification


  • Xrm.Page.ui.clearFormNotification()
    • Clears the form notification

All Controls

  • Xrm.Page.getControl("new_name").setNotification("Field specific notification")
    • Sets a notification specific to the field


  • Xrm.Page.getControl(“new_name”).clearNotification()
    • Clears the field specific notification

Number Fields

  • Xrm.Page.getAttribute("new_precision").setPrecision(2)
    • Override field’s precision

Date Fields

  • Xrm.Page.getControl("createdon").setShowTime(true)
    • Controls whether to show the time for a date field

Lookup Fields

  • Xrm.Page.getControl("ownerid").addCustomFilter(fetchFilter, entityType)
    • Applies a custom filter to the lookup view
    • entityType is optional and if it is not passed it will default to all entity views
  • Xrm.Page.getControl("ownerid").addPreSearch(handler)
    • triggers right before a lookup dialog pops open
  • Xrm.Page.getControl("ownerid").removePreSearch(handler)
    • removes event handler set from the addPreSearch method


  • Xrm.Utility.openWebResourceDialog(webResourceName, webResourceData, width, height)
    • opens a specified HTML web resource as a dialog


  1. Thanks for the article. It's worth pointing out that the 'openWebResourceDialog' has been postponed until a later release.
    There are also Xrm.Utility functions for alertDialog and confirmDialog that replace the window.alert and window.confirm methods so that these dialogs can be supported on a tablet/mobile device. Code that uses window.alert and window.confirm today will be mapped to the new functions, but in the future support for the window methods will be dropped making it important to start using the new methods.

    Posted by: Scott Durow  |  Sep 24, 2013 2:36:28 AM

  2. Thanks for the update Scott!

    Posted by: Blake Scarlavai  |  Sep 24, 2013 8:39:40 AM

  3. Thanks for the update. Do you know if they have an update of the XrmPage-vsdoc.js so we can have intellisense for these new functions?

    Posted by: Dustin Warner  |  Dec 10, 2013 8:24:54 AM

  4. Hello

    I have an issue with my fields that are not set as visible by default on the form. But in JavaScript when I call:


    it returns true. The call is expected to return 'false' because my my_field is not visible by default on the form.

    any suggestions?

    Posted by: Javid  |  Mar 19, 2015 5:41:31 AM

Post a Comment

  • *Required

Contact Us for a Quote, or Personalized Demonstrationof Microsoft Dynamics CRM for Your Business.

Contact Us