If you’ve been following, I had a series of Client API posts late last year. Below I have regrouped the new Client API functionality in a table for reference. This can become helpful especially if you are developing with the “old” CRM 2011 mindset to easily see what you can achieve differently and/or more efficiently in CRM 2013. Details on the new functionalities is available on the Microsoft Dynamics CRM YouTube video and in the CRM 2013 SDK.
Area |
Method and Syntax |
Description |
Data |
Xrm.Page.data.refresh(save).then(successCallback, errorCallback) |
Asynchronously refreshes and optionally saves all the data of the form without reloading the page. You can pass a callback method to execute on success or error |
Data |
Xrm.Page.data.save().then(successCallback, errorCallback) |
See my blog post on this here |
Data |
Xrm.Page.data.getIsValid() |
Returns a Boolean value indicating if the form can be saved or not |
Data |
Xrm.Page.data.setFormDirty() |
Set the form as dirty |
Entity |
Xrm.Page.data.entity.getPrimaryAttributeValue() |
Gets a string for the value of the primary attribute of the entity. |
UI |
Xrm.Page.ui.setFormNotification(message, level, uniqueId); Xrm.Page.ui.clearFormNotification(uniqueId) |
Use setFormNotification to display form level notifications and clearFormNotification to remove notifications. Gareth Tucker has a great article on these here. |
Controls |
Xrm.Page.getControl(fieldName).setNotification(message) Xrm.Page.getControl(fieldName).clearNotification() |
See article linked above for details. Notifications can be set at the field level |
Number |
Xrm.Page.getAttribute(fieldName).setPrecision(precision) |
This method is used to override the field’s precision |
Date |
Xrm.Page.getControl(arg).setShowTime(bool) |
Specify whether a date control should show the time portion of the date. |
Date |
Xrm.Page.getControl(arg).setIsAllDay(bool) |
Specify whether a date control should set a value including the entire day. |
Lookup |
Xrm.Page.getControl(arg).addCustomFilter(filter, entityLogicaName) |
Use add additional filters to the results displayed in the lookup. Each filter will be combined with any previously added filters as an ‘AND’ condition The entity logical name is optional. If this is set the filter will only apply to that entity type. Otherwise it will apply to all types of entities returned. |
Lookup |
Xrm.Page.getControl(arg).addPreSearch(handler) |
Use this method to apply changes to lookups based on values current just as the user is about to view results for the lookup. The argument is a function that will be run just before the search to provide results for a lookup occurs. You can use this handler to call one of the other lookup control functions and improve the results to be displayed in the lookup. |
Lookup |
Xrm.Page.getControl(arg).removePreSearch(handler) |
This API call is used to remove event handler functions that have previously been set for the PreSearch event (see above) |
Context |
Xrm.Page.context.getUserName() |
Returns the name of the current user. |
Context |
Xrm.Page.context.client.getClient() Xrm.Page.context.client.getClientState() |
See my blog post about it here |
Utility |
Xrm.Utility.alertDialog(message,onCloseCallback) Xrm.Utility.confirmDialog(message,yesCloseCallback,noCloseCallback) |
Displays a dialog box containing an application-defined message. Displays a confirmation dialog box that contains an optional message as well as OK and Cancel buttons. See additional notes on this here. |
Utility |
Xrm.Utility.isActivityType(entityName) |
Determine if an entity is an activity entity. |
Utility |
Xrm.Utility.openEntityForm(name,id,parameters) |
Opens an entity form. Parameters are optional and used to pass the form ID, set default field values or pass custom query string parameters |
Utility |
Xrm.Utility.openWebResource(webResourceName,webResourceData,width, height) |
Opens an HTML web resource. |
Salut Salim, est-ce que ça se peut que la méthode setFormDirty() ne soit plus disponible? Je ne la vois pas dans le SDK
Salut Francois! Effectivement, elle n’existe plus.. Il faut utiliser setSubmitMode pour avoir un comportement un peu similaire: http://msdn.microsoft.com/en-us/library/gg334409.aspx#BKMK_setSubmitMode
Merci Salim 🙂 . Bien dommage qu’ils l’aient retiré. Je vais essayer ta solution 🙂
[…] Client API Enhancement Microsoft Dynamics CRM 2013 SDK New Features – Client API (video) CRM 2013 – Client API New Functionalities Recap Microsoft Dynamics CRM 2013 Client API Cheat Sheet v1.1 […]