Microsoft Dynamics CRM 2013 is providing some exciting new methods we can use with the JavaScript SDK on the entity forms, such as :
- Easier way to set the form dirty
- Custom lookup filters
- Displaying form notifications as well as field specific notifications.
- 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
- Xrm.Page.data.refresh()
- Asynchronously refresh data on form without reloading the page
- Can pass in a callback to execute on error or success
- Xrm.Page.data.save()
- Asynchronously save the form
- Can pass in a callback to execute on error or success
- Xrm.Page.data.getIsValid()
- Returns a boolean telling whether the form can be saved or not
- Xrm.Page.data.setFormDirty()
- Sets the form as dirty
- Xrm.Page.data.entity.getPrimaryAttributeValue()
- 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
- 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
- Xrm.Page.getAttribute(“new_precision”).setPrecision(2)
- Override field’s precision
- Xrm.Page.getControl(“createdon”).setShowTime(true)
- Controls whether to show the time for a date field
- 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