Skip to content

Commit 4cfa0ed

Browse files
committed
check
1 parent e2d898b commit 4cfa0ed

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

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

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,25 @@ The `OnRecordSelect` event occurs when a single row (record) is selected in the
1919

2020
## Example: Override the default open behavior in model-driven grids
2121

22-
There might be situations where you don't want the table record to open (which is the default behavior), but want a custom action to be performed such as opening a URL using JavaScript functions. Here is an example to achieve this using the [Power Apps grid control](../../../../../maker/model-driven-apps/the-power-apps-grid-control.md) and the `OnRecordSelect` event.
22+
There might be situations where you don't want the table record to open (which is the default behavior), but want a custom action to be performed such as opening a URL using JavaScript functions. Here is an example to achieve this using the [Power Apps grid control](../../../../../maker/model-driven-apps/the-power-apps-grid-control.md) and the `OnRecordSelect` event. The following function will ensure that the record opens using the form specified `pageInput` `formId` value.
2323

2424
### Step 1: Create a web resource
2525

2626
Create, save and publish a JavaScript (JS) web resource that contains the following code:
2727

2828
```JavaScript
29-
function OnSelect(context) {
29+
var Example = window.Example || {};
30+
(function () {
31+
this.OnSelect = function (executionContext) {
3032
var pageInput = {
31-
pageType: "entityrecord",
32-
entityName: "contact",
33-
entityId: context.getFormContext().data.entity.getId()
33+
pageType: "entityrecord",
34+
entityName: executionContext.getEventSource().getEntityName(),
35+
entityId: executionContext.getEventSource().getId(),
36+
formId: "420786E3-D342-4A9A-914B-AA331FF2D25E"
3437
};
3538
Xrm.Navigation.navigateTo(pageInput);
3639
}
40+
}).call(Example);
3741
```
3842

3943
More information: [Create or edit model-driven app web resources](../../../../../maker/model-driven-apps/create-edit-web-resources.md)
@@ -50,9 +54,8 @@ Follow these steps to enable the **Power Apps Grid Control** as the main grid (t
5054
When enabling the **Power Apps Grid Control**, an **Events** tab appears. Select the **Events** tab:
5155

5256
1. Under the **Form Libraries** section, add the Form Library from the web resource just created.
53-
1. Under the **Event Handlers** section, select the event **OnRecordSelect** and click **Add**, a popup will appear.
54-
1. In the popup, select the form library just added and the function name **OnSelect**. This is the name of the JavaScript function created in the web resource.
55-
57+
1. Under the **Event Handlers** section, select the event **OnRecordSelect** and click Add, a popup will appear.
58+
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**.
5659

5760
More information: [Power Apps grid control](../../../../../maker/model-driven-apps/the-power-apps-grid-control.md)
5861

0 commit comments

Comments
 (0)