Home > CRM 2013 > New JScript syntaxes – CRM 2013

New JScript syntaxes – CRM 2013

With the advent of CRM 2013, below are the new set of client API methods

CRM 2013 Client API

CRM 2013 Client API

Context

  • Xrm.Page.context.getUserName() Returns username of the currently logon user
  • Xrm.Page.context.getClient() Returns the client (i.e., Returns “Outlook”, “Web”, or “Mobile”)
  • Xrm.Page.context.client.getClientState()Returns  whether user is working online or offline.

Note – Xrm.Page.context.isOutlookOnline and isOutlookClient methods are deprecated

Data

  • Xrm.Page.data.refresh()Asynchronously refresh data on form without reloading the page
  • Xrm.Page.data.Save().then(successCallback, errorCallback) Allows you to save the record asynchronously with the option to set callback functions to be executed after the save operation is completed.
  • Xrm.Page.data.getIsValid() Validates the form and returns a Boolean.
  •  Xrm.Page.data.setFormDirty() – Allows to set IsDirty options on the form to (true/false).

Entity

  • Xrm.Page.data.entity.getPrimaryAttributeValue() Returns a string value of the primary attribute for the entity.

Xrm.Utility

  • Xrm.Utility.openWebResourceDialog(webResourceName,webResourceData,width,height) Displays html web resource as dialogs window.
  • Xrm.Utility.alertDialog(message,onCloseCallback) Displays alert box with a callback function.
  • Xrm.Utility.confirmDialog(message,yesCloseCallback,noCloseCallback) Displays confirm dialog with different callbacks depending on Yes/No button clicks.

 Set Notifications

  • Check this link for syntaxes

Number Fields

  •      Xrm.Page.ui.controls.get(controlName).setPrecision(2) – Overrides field’s precision

Date Fields

  •    Xrm.Page.ui.controls.get(controlName).setShowTime(true) Controls whether to show the time for a date field.
  •    Xrm.Page.ui.controls.get(controlName).setIsAllDay()Allows to set the date control to all day date time.

Look up Fields

  •    Xrm.Page.ui.controls.get(controlName).addCustomFilter(filter,entityLogicaName)
    •    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.ui.controls.get(controlName).addPreSearch(handler)Allows to add additional logic that will occur just before the search dialog box
  •   Xrm.Page.ui.controls.get(controlName).removePreSearch(handler)Removes event handler functions that previously been set in addPreSearch event.

🙂

Advertisement
Categories: CRM 2013 Tags: ,
  1. No comments yet.
  1. No trackbacks yet.

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 )

Connecting to %s

%d bloggers like this: