Pages

Thursday 25 July 2019

CRM2016 Java script obsolete and Dynamics 365 version 9 replacement java script


XRM object is globally available.

CRM2016
Xrm.Page
verison 9
ExecutionContext.getFormContext

CRM2016
Xrm.Page.context.getUserId
verison 9
Xrm.Utility.getGlobalContext().userSettings.userId

 CRM2016
Xrm.Page.context
verison 9
Xrm.Utility.getGlobalContext

 CRM2016
Xrm.Page.context.getUserId
verison 9
Xrm.Utility.getGlobalContext().userSettings.userId

 CRM2016
openEntityForm
verison 9
Xrm.Navigation.openForm'

 CRM2016
Xrm.Page.context.getUserLcid

verison 9
Xrm.Utility.getGlobalContext().userSetings.languageId

Monday 1 July 2019

Client API Xrm object - Components of Xrm Object

The Xrm object is globally available to use in your code without having to use the execution context in Client API.

Below are the components of Xrm object

Xrm.DeviceProvides methods to use native device capabilities of mobile devices.
Xrm.EncodingProvides methods to encode strings
.Xrm.NavigationProvides methods for navigating forms and items in model-driven apps
.Xrm.PanelProvides a method to display a web page in the side pane of model-driven apps form.
Xrm.UtilityProvides a container for useful methods.
Xrm.WebApiProvides methods to use Web API to create and manage records and execute Web API actions and functions.
Xrm.WebApi.offline: Provides methods to create and manage records in the model-driven apps mobile clients while working in the offline mode.
Xrm.WebApi.online: Provides methods to use Web API to create and manage records and execute Web API actions and functions when connected to the server.

Dynamics 365 Root objects in the Client API object model


At the root of the Client API object model are the following contexts and the Xrm object:
ObjectDescription
executionContextRepresents the execution context for an event in model-driven apps forms and grids.
More information: Client API execution context
formContextProvides a reference to a form or an item on the form against which the current code executes. To get the formContext object, use the executionContext.getFormContext method.
More information: Client API form context
gridContextProvides a reference to a grid or a subgrid on a form against which the current code executes.
More information: Client API grid context
XrmProvides a global object for performing operations that do not directly impact the data and UI in forms, grids, subgrids, controls, or attributes. For example, navigate forms, create and manage records using Web API.
More information: Client API Xrm object

Deprecated methods in v9.0 (xrm.utility)

Syntax Difference Between CRM2016 and Version 9 (FormContext)

In CRM2016 , the global Xrm.Page object was used to represent a form or an item on the form. With the latest version, the Xrm.Page object is deprecated, and you should use the getFormContext method of the passed in execution context object to return reference to the appropriate form or an item on the form.


CRM2016
function displayName()
{
var firstName = Xrm.Page.getAttribute("new_field1").getValue();
var lastName = Xrm.Page.getAttribute("new_field2").getValue();
console.log(firstName + " " + lastName);

}


Latest Version CRM
function displayName(executionContext)
{
var formContext = executionContext.getFormContext(); // get formContext

// use formContext instead of Xrm.Page
var firstName = formContext.getAttribute("new_field").getValue(); 
var lastName = formContext.getAttribute("new_field").getValue();
console.log(firstName + " " + lastName);

}