CRM 2013 SDK New Features – Client API

With CRM 2013, some important features have been released under Client API. Most of them are good solutions to very practical scenarios that CRM developers faced in past releases. This is an attempt to present the official video and to summarize SDK features for the reference.

The video can be found in the following link as well.

http://community.dynamics.com/crm/b/crmvideos/archive/2013/11/09/microsoft-dynamics-crm-2013-sdk-new-features-client-api.aspx

Following table summarizes New SDK features under CRM 2013.

Area Method and Syntax Description
Data Xrm.Page.data.refresh(save).then(successCallbackerrorCallback) 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)
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(messageleveluniqueId);

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 thePreSearch 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()

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 andCancel buttons.

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.
Advertisements

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