Changes in Client API or Client Script in Dynamics 365 for Customer Engagement


If you are a CRM developer and want to write Client Script in Dynamics 365 then you are at right place. There are huge changes in Client API in Dynamics 365 for Customer Engagement.

From CRM 2011 we are familiar with XRM.Page but it is deprecated in Dynamics 365 for Customer engagement and it has been replaced with ExecutionContext.getFormContext.

What is Execution Context:
The execution context defines the event context in which your code executes. The execution context is passed when an event occurs on a form or grid, which you can use it in your event handler to perform various tasks such as determine formContext or gridContext, or manage the save event.

Execution context was already in previous version of CRM but we can easily access other client API by XRM.Page hence we did not use it always.

You will get more details at below link:

What changed in Code:

Lets take example of set value and get value:

Before Dynamics 365 V 9.0( In CRM 2016, 2015, 2013 and 2011) we write code as below:

function onSave()
{
var name = XRM.Page.getAttribute("name").getValue();
        XRM.Page.getAttribute("new_name").setValue(name);
}

In Dynamics 365 V 9.0, we write code as below

function onSave(executionContext)
{
var formContext = executionContext.getFormContext();
var name = formContext.getAttribute("name").getValue();
        formContext.getAttribute("new_name").setValue(name);
}

If you want to read more deprecated functionalities then click on below link:


Cheers,
Rocker

Comments

Popular posts from this blog

Power Automate: Create and attach Dataverse note or activity with an entity record through MS flow

{Error:Fetch XML}: The date/time format is not valid, or the value is outside the supported range

How to set privilege for Activity Attachment (activitymimeattachment) in Dynamics 365 or PowerApps