Skip to content

Commit a7e556c

Browse files
authored
Merge pull request MicrosoftDocs#4538 from MicrosoftDocs/main638247205687437570sync_temp
Repo sync for protected CLA branch
2 parents 9f279bf + bd4132c commit a7e556c

File tree

2 files changed

+46
-3
lines changed

2 files changed

+46
-3
lines changed

powerapps-docs/developer/model-driven-apps/clientapi/reference/events/grid-onrecordselect.md

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,63 @@ title: "Grid OnRecordSelect event (Client API reference) in model-driven apps| M
33
description: Includes description and supported parameters for the grid OnRecordSelect event.
44
author: jasongre
55
ms.author: jasongre
6-
ms.date: 03/12/2022
6+
ms.date: 06/29/2023
77
ms.reviewer: jdaly
88
ms.topic: reference
99
applies_to: "Dynamics 365 (online)"
1010
search.audienceType:
1111
- developer
1212
contributors:
1313
- JimDaly
14+
- ericregnier
1415
---
1516
# Grid OnRecordSelect event (Client API reference)
1617

17-
The `OnRecordSelect` event occurs when a single row (record) is selected in the editable grid. This event won't occur if a user selects different cells in the same row, or selects multiple rows.
18+
The `OnRecordSelect` event occurs when a single row (record) is selected in an editable grid. This event doesn't occur if a user selects different cells in the same row, or selects multiple rows.
1819

20+
## Example: Override the default open behavior in model-driven grids
1921

22+
When you want to customize the way that a table record opens from the [Power Apps grid control](../../../../../maker/model-driven-apps/the-power-apps-grid-control.md), you can control how this opens with a JavaScript function associated with the grid `OnRecordSelect` event.
23+
24+
The following example ensures that the record opens using the form specified by the `pageInput` `formId` value using the [Xrm.Navigation.navigateTo](../Xrm-Navigation/navigateTo.md) method. In this example, the form and grid must belong to the same entity.
25+
26+
### Step 1: Create a web resource
27+
28+
Create, save, and publish a JavaScript (JS) web resource that contains the following code:
29+
30+
```JavaScript
31+
var Example = window.Example || {};
32+
(function () {
33+
this.OnSelect = function (executionContext) {
34+
var pageInput = {
35+
pageType: "entityrecord",
36+
entityName: executionContext.getEventSource().getEntityName(),
37+
entityId: executionContext.getEventSource().getId(),
38+
formId: "420786E3-D342-4A9A-914B-AA331FF2D25E"
39+
};
40+
Xrm.Navigation.navigateTo(pageInput);
41+
}
42+
}).call(Example);
43+
```
44+
45+
More information: [Create or edit model-driven app web resources](../../../../../maker/model-driven-apps/create-edit-web-resources.md)
46+
47+
### Step 2: Enable Power Apps Grid Control
48+
49+
Follow these steps to enable the **Power Apps grid control** as the main grid (table view) or within a model-driven form subgrid:
50+
51+
- [Use as main grid](../../../../../maker/model-driven-apps/the-power-apps-grid-control.md#add-the-power-apps-grid-control-to-views-for-an-entity)
52+
- [Use as subgrid](../../../../../maker/model-driven-apps/the-power-apps-grid-control.md#add-the-power-apps-grid-control-to-a-subgrid)
53+
54+
### Step 3: Register the custom behavior on OnRecordSelect Event
55+
56+
When you enable the **Power Apps grid control**, an **Events** tab appears. Select the **Events** tab:
57+
58+
1. Under the **Form Libraries** section, add the Form Library from the web resource created.
59+
1. Under the **Event Handlers** section, select the event **OnRecordSelect** and select **Add** and a popup appears.
60+
1. In the popup, select the form library just added and the function name `Example.OnSelect`. This is the name of the JavaScript function created in the web resource. Make sure to check the option **Pass execution context as first parameter**.
61+
62+
More information: [Power Apps grid control](../../../../../maker/model-driven-apps/the-power-apps-grid-control.md)
2063

2164

2265

powerapps-docs/maker/common/responsible-ai-overview.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@ ms.reviewer: mduelae
1616

1717
[!INCLUDE[responsible-ai-features](../../includes/responsible-ai-features.md)]
1818

19-
- [FAQs for building apps through conversation](faqs-build-apps-conversation.md)
19+
- [FAQ for building apps through conversation](faqs-build-apps-conversation.md)
2020
- [Build apps through conversation (preview)](../canvas-apps/ai-conversations-create-app.md)

0 commit comments

Comments
 (0)