Sonoma Partners Microsoft CRM and Blog

CRM 2013 New Client API Methods

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
Topics: Microsoft Dynamics CRM 2013