---
title: Avoid Using Deprecated Event Registration And Handling Methods
description: "**Impact area** Manageability **Severity** High **Affected element** ## Rule number **DY-0004** ## Impact The Power Apps component framework is the preferred way to define event registration and handling methods. ## Remediation Refactor your code to use the new API signatures.…"
url: "https://community-staging.qualityclouds.com/qcdocs/qc/dynamics-365-rules/avoid-using-deprecated-event-registration-and-handling-methods/"
updated: "2025-03-21"
category: Dynamics 365 Rules
---

# Avoid Using Deprecated Event Registration And Handling Methods

**Impact area**

Manageability

**Severity**

High

**Affected element**

## Rule number

**DY-0004**

## Impact

The Power Apps component framework is the preferred way to define event registration and handling methods.

## Remediation

Refactor your code to use the new API signatures.

### Time to fix

15 min

## Best practice related

This article is based on the Microsoft Power Platform doc page. See the original article on the Microsoft documentation site: [Important changes coming: Some client APIs are deprecated](https://docs.microsoft.com/en-us/power-platform/important-changes-coming). 

The following client APIs are deprecated to reorganize the Xrm client API object model to better align with the need of using the same client scripts without having to change them based on the context or the client (web client or the new Unified Interface) where they run. You should plan to use the new client APIs mentioned in the **Replacement Client API** column instead of the deprecated ones. The deprecated client APIs will continue to be available and supported until they are officially removed from a future major release. 

| Deprecated client API | Replacement client API | Comments |
| --- | --- | --- |
| [Xrm.Page](https://docs.microsoft.com/en-us/previous-versions/dynamicscrm-2015/developers-guide/gg328474(v%3dcrm.7)) | **Forms**: ExecutionContext.[getFormContext](https://docs.microsoft.com/en-us/dynamics365/customer-engagement/developer/clientapi/reference/executioncontext/getformcontext) **Commands**: Send it as the [PrimaryControl](https://docs.microsoft.com/en-us/dynamics365/customer-engagement/developer/customize-dev/pass-dynamics-365-data-page-parameter-ribbon-actions#form-and-grid-context-in-ribbon-actions) parameter | Use of the **Xrm.Page** object as a static access to the primary form context is still supported to maintain backward compatibility with the existing scripts. Based on the feedback, we understand that the usage of **Xrm.Page** is high, and it won't be removed as soon as some other client API methods listed in this section. We encourage you to use the new way of getting form content where possible. More information: [Client API form context](https://docs.microsoft.com/en-us/dynamics365/customer-engagement/developer/clientapi/clientapi-form-context) Although **Xrm.Page** is deprecated, **parent.Xrm.Page** will continue to work in case of HTML web resources embedded in forms as this is the only way to access the form context from the HTML web resource. |
| [Xrm.Page.context](https://docs.microsoft.com/en-us/previous-versions/dynamicscrm-2015/developers-guide/gg334511(v%3dcrm.7)) | Xrm.Utility.[getGlobalContext](https://docs.microsoft.com/en-us/dynamics365/customer-engagement/developer/clientapi/reference/xrm-utility/getglobalcontext) | Allows access to the global context without going through the form context. |
| [Xrm.Page.context.getQueryStringParameters](https://docs.microsoft.com/en-us/previous-versions/dynamicscrm-2015/developers-guide/gg334511(v%3dcrm.7)#getquerystringparameters) | formContext.data.attributes | The formContext.data.attributes API will make retrieval of non-entity bound data consistent across entity forms, metadata-driven dialogs, and task-based flows. The data will be a combination of custom values sent using the query string and what was specified in the parameters in the [openForm](https://docs.microsoft.com/en-us/dynamics365/customer-engagement/developer/clientapi/reference/xrm-navigation/openform) method. |
| [Xrm.Page.context.getTimeZoneOffsetMinutes](https://docs.microsoft.com/en-us/previous-versions/dynamicscrm-2015/developers-guide/gg334511(v=crm.7)#gettimezoneoffsetminutes) | globalContext.userSettings.getTimeZoneOffsetMinutes | Moved to globalContext.userSettings |
| [Xrm.Page.context.getUserId](https://docs.microsoft.com/en-us/previous-versions/dynamicscrm-2015/developers-guide/gg334511(v=crm.7)#getuserid) | globalContext.userSettings.userId | Moved to globalContext.userSettings |
| [Xrm.Page.context.getUserLcid](https://docs.microsoft.com/en-us/previous-versions/dynamicscrm-2015/developers-guide/gg334511(v=crm.7)#getuserlcid) | globalContext.userSettings.languageId | Moved to globalContext.userSettings |
| [Xrm.Page.context.getUserName](https://docs.microsoft.com/en-us/previous-versions/dynamicscrm-2015/developers-guide/gg334511(v=crm.7)#getusername) | globalContext.userSettings.userName | Moved to globalContext.userSettings |
| [Xrm.Page.context.getUserRoles](https://docs.microsoft.com/en-us/previous-versions/dynamicscrm-2015/developers-guide/gg334511(v=crm.7)#getuserroles) | globalContext.userSettings.securityRoles | Moved to globalContext.userSettings |
| [Xrm.Page.context.getIsAutoSaveEnabled](https://docs.microsoft.com/en-us/previous-versions/dynamicscrm-2015/developers-guide/gg334511(v=crm.7)#getisautosaveenabled) | globalContext.organizationSettings.isAutoSaveEnabled | Moved to globalContext.organizationSettings |
| [Xrm.Page.context.getOrgLcid](https://docs.microsoft.com/en-us/previous-versions/dynamicscrm-2015/developers-guide/gg334511(v=crm.7)#getorglcid) | globalContext.organizationSettings.languageId | Moved to globalContext.organizationSettings |
| [Xrm.Page.context.getOrgUniqueName](https://docs.microsoft.com/en-us/previous-versions/dynamicscrm-2015/developers-guide/gg334511(v=crm.7)#getorguniquename) | globalContext.organizationSettings.uniqueName | Moved to globalContext.organizationSettings |
| [Xrm.Page.data.entity.getDataXml](https://docs.microsoft.com/en-us/previous-versions/dynamicscrm-2015/developers-guide/gg334720(v%3dcrm.7)#getdataxml) | No change in the method, but use "typename" instead of type for lookup attributes. |  |
| [GridRow.getData](https://docs.microsoft.com/en-us/previous-versions/dynamicscrm-2015/developers-guide/dn932126(v%3dcrm.7)#getdata) | GridRow.data | GridRow is essentially a form context. This change unifies the interface of GridRow with formContext. |
| [GridRowData.getEntity](https://docs.microsoft.com/en-us/previous-versions/dynamicscrm-2015/developers-guide/dn932126(v=crm.7)#getentity) | GridRowData.entity | GridRowData is form data. This change unifies the interface of GridRowData with formContextData. |
| [Xrm.Mobile.offline](https://docs.microsoft.com/en-us/previous-versions/dynamicscrm-2016/developers-guide/mt787123(v=crm.8)) | [Xrm.WebApi.offline](https://docs.microsoft.com/en-us/dynamics365/customer-engagement/developer/clientapi/reference/xrm-webapi/offline) | Moved the offline-related methods under **Xrm.WebApi.offline** |
| [parent.Xrm](https://docs.microsoft.com/en-us/previous-versions/dynamicscrm-2015/developers-guide/gg309536(v%3dcrm.7)#reference-other-web-resources-from-an-html-web-resource) | Use one of the following: a) Use a custom control created using [Power Apps component framework](https://docs.microsoft.com/en-us/powerapps/developer/component-framework/overview) instead of HTML web resources. b) On forms, use the [getContentWindow](https://docs.microsoft.com/en-us/powerapps/developer/model-driven-apps/clientapi/reference/controls/getcontentwindow) method of the web resource control. c) If the [getContentWindow](https://docs.microsoft.com/en-us/powerapps/developer/model-driven-apps/clientapi/reference/controls/getcontentwindow) method doesn't work, you can use `parent.Xrm` to get to the `Xrm` object inside an HTML web resource. If the HTML web resource is opened in a new window, then you should use `opener.Xrm` instead. | **Earlier**: An HTML web resource may interact with the **Xrm.Page** or **Xrm.Utility** objects within the form by using **parent.Xrm.Page** or **parent.Xrm.Utility**. **Now**: parent.Xrm.* will work if the HTML web resource is loaded in a form container. It won't work for HTML web resources that are stand alone, or referenced from the site map or any other places. **NOTE**: `parent.Xrm` will be removed after the removal of the `ClientGlobalContext.js.aspx` page; dates yet to be announced. |
| [addOnKeyPress](https://docs.microsoft.com/en-us/previous-versions/dynamicscrm-2016/developers-guide/gg334266(v=crm.8)#addonkeypress) | Use a custom control created using [Power Apps component framework](https://docs.microsoft.com/en-us/powerapps/developer/component-framework/overview) |  |
| [fireOnKeyPress](https://docs.microsoft.com/en-us/previous-versions/dynamicscrm-2016/developers-guide/gg334266(v=crm.8)#fireonkeypress) | Use a custom control created using [Power Apps component framework](https://docs.microsoft.com/en-us/powerapps/developer/component-framework/overview) |  |
| [removeOnKeyPress](https://docs.microsoft.com/en-us/previous-versions/dynamicscrm-2016/developers-guide/gg334266(v=crm.8)#removeonkeypress) | Use a custom control created using [Power Apps component framework](https://docs.microsoft.com/en-us/powerapps/developer/component-framework/overview) |  |
| [showAutoComplete](https://docs.microsoft.com/en-us/previous-versions/dynamicscrm-2016/developers-guide/gg334266(v=crm.8)#showautocomplete) | Use a custom control created using [Power Apps component framework](https://docs.microsoft.com/en-us/powerapps/developer/component-framework/overview) |  |
| [hideAutoComplete](https://docs.microsoft.com/en-us/previous-versions/dynamicscrm-2016/developers-guide/gg334266(v=crm.8)#hideautocomplete) | Use a custom control created using [Power Apps component framework](https://docs.microsoft.com/en-us/powerapps/developer/component-framework/overview) |  |
| [Xrm.Utility.alertDialog](https://docs.microsoft.com/en-us/previous-versions/dynamicscrm-2015/developers-guide/jj602956(v%3dcrm.7)#alertdialog) | Xrm.Navigation.[openAlertDialog](https://docs.microsoft.com/en-us/dynamics365/customer-engagement/developer/clientapi/reference/xrm-navigation/openalertdialog) | The new signature is consistent with other APIs (openForm) and takes a new set of parameters for flexibility. |
| [Xrm.Utility.confirmDialog](https://docs.microsoft.com/en-us/previous-versions/dynamicscrm-2015/developers-guide/jj602956(v%3dcrm.7)#confirmdialog) | Xrm.Navigation.[openConfirmDialog](https://docs.microsoft.com/en-us/dynamics365/customer-engagement/developer/clientapi/reference/xrm-navigation/openconfirmdialog) | The new signature is consistent with other APIs (openForm) and takes a new set of parameters for flexibility. |
| [Xrm.Utility.getBarcodeValue](https://docs.microsoft.com/en-us/previous-versions/dynamicscrm-2016/developers-guide/jj602956(v=crm.8)#getbarcodevalue) | Xrm.Device.[getBarcodeValue](https://docs.microsoft.com/en-us/powerapps/developer/model-driven-apps/clientapi/reference/xrm-device/getbarcodevalue) | Moving device-related actions to Xrm.Device |
| [Xrm.Utility.getCurrentPosition](https://docs.microsoft.com/en-us/previous-versions/dynamicscrm-2016/developers-guide/jj602956(v=crm.8)#getcurrentposition) | Xrm.Device.[getCurrentPosition](https://docs.microsoft.com/en-us/powerapps/developer/model-driven-apps/clientapi/reference/xrm-device/getcurrentposition) | Moving device-related actions to Xrm.Device |
| [Xrm.Utility.isActivityType](https://docs.microsoft.com/en-us/previous-versions/dynamicscrm-2015/developers-guide/jj602956(v%3dcrm.7)#isactivitytype) | Xrm.Utility.[getEntityMetadata](https://docs.microsoft.com/en-us/dynamics365/customer-engagement/developer/clientapi/reference/xrm-utility/getentitymetadata) | The isActivityType method is synchronous so it was suitable for ribbon rules. However, the replacement method, [getEntityMetadata](https://docs.microsoft.com/en-us/dynamics365/customer-engagement/developer/clientapi/reference/xrm-utility/getentitymetadata), is asynchronous, and is not suitable for ribbon rules. |
| [Xrm.Utility.openEntityForm](https://docs.microsoft.com/en-us/previous-versions/dynamicscrm-2015/developers-guide/jj602956(v%3dcrm.7)#openentityform) | Xrm.Navigation.[openForm](https://docs.microsoft.com/en-us/dynamics365/customer-engagement/developer/clientapi/reference/xrm-navigation/openform) | Moving navigation actions to Xrm.Navigation |
| [Xrm.Utility.openQuickCreate](https://docs.microsoft.com/en-us/previous-versions/dynamicscrm-2015/developers-guide/jj602956(v%3dcrm.7)#openquickcreate) | Xrm.Navigation.[openForm](https://docs.microsoft.com/en-us/dynamics365/customer-engagement/developer/clientapi/reference/xrm-navigation/openform) | Moving navigation actions to Xrm.Navigation |
| [Xrm.Utility.openWebResource](https://docs.microsoft.com/en-us/previous-versions/dynamicscrm-2015/developers-guide/jj602956(v%3dcrm.7)#openwebresource) | Xrm.Navigation.[openWebResource](https://docs.microsoft.com/en-us/dynamics365/customer-engagement/developer/clientapi/reference/xrm-navigation/openwebresource) | Moving navigation actions to Xrm.Navigation **Note**: This API returns VOID in Unified Interface. |
| [globalContext.organizationSettings.baseCurrencyId](https://docs.microsoft.com/en-us/powerapps/developer/model-driven-apps/clientapi/reference/xrm-utility/getglobalcontext/organizationsettings#basecurrencyid) | [globalContext.organizationSettings.baseCurrency](https://docs.microsoft.com/en-us/powerapps/developer/model-driven-apps/clientapi/reference/xrm-utility/getglobalcontext/organizationsettings#basecurrency) | The replacement method lets you access the display name along with the ID of transaction currency. |
| [globalContext.userSettings.securityRoles](https://docs.microsoft.com/en-us/powerapps/developer/model-driven-apps/clientapi/reference/xrm-utility/getglobalcontext/usersettings#securityroles) | [globalContext.userSettings.Roles](https://docs.microsoft.com/en-us/powerapps/developer/model-driven-apps/clientapi/reference/xrm-utility/getglobalcontext/usersettings#roles) | The replacement method lets you access the display name along with the ID of the security roles. |
| [globalContext.userSettings.transactionCurrencyId](https://docs.microsoft.com/en-us/powerapps/developer/model-driven-apps/clientapi/reference/xrm-utility/getglobalcontext/usersettings#transactioncurrencyid) | [globalContext.userSettings.transactionCurrency](https://docs.microsoft.com/en-us/powerapps/developer/model-driven-apps/clientapi/reference/xrm-utility/getglobalcontext/usersettings#transactioncurrency) | The replacement method lets you access the display name along with the ID of transaction currency. |
| [getData](https://docs.microsoft.com/en-us/powerapps/developer/model-driven-apps/clientapi/reference/controls/getdata) and [setData](https://docs.microsoft.com/en-us/powerapps/developer/model-driven-apps/clientapi/reference/controls/setdata) for Silverlight web resources | None | Silverlight is no longer supported. These methods won't be available after October 2020. |
| [formContext.data.entity.save](https://docs.microsoft.com/en-us/powerapps/developer/model-driven-apps/clientapi/reference/formcontext-data-entity/save) | [formContext.data.save](https://docs.microsoft.com/en-us/powerapps/developer/model-driven-apps/clientapi/reference/formcontext-data/save) |  |
| [ClientGlobalContext.js.aspx](https://docs.microsoft.com/en-us/powerapps/developer/model-driven-apps/clientapi/reference/getglobalcontext-clientglobalcontext.js.aspx#clientglobalcontextjsaspx) | None | The ClientGlobalContext.js.aspx page is deprecated and scheduled to be unavailable after October 1, 2021. Alternative methods to access global context information will be available before April 1, 2021. |

For information about the new client APIs, see [Apply business logic using client scripting in model-driven apps using JavaScript](https://docs.microsoft.com/en-us/powerapps/developer/model-driven-apps/client-scripting).
