Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
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.
When you want to customize the way that a table record opens from the Power Apps grid control, you can control how this opens with a JavaScript function associated with the grid OnRecordSelect
event.
The following example ensures that the record opens using the form specified by the pageInput
formId
value using the Xrm.Navigation.navigateTo method. In this example, the form and grid must belong to the same entity.
Create, save, and publish a JavaScript (JS) web resource that contains the following code:
var Example = window.Example || {};
(function () {
this.OnSelect = function (executionContext) {
var pageInput = {
pageType: "entityrecord",
entityName: executionContext.getEventSource().getEntityName(),
entityId: executionContext.getEventSource().getId(),
formId: "420786E3-D342-4A9A-914B-AA331FF2D25E"
};
Xrm.Navigation.navigateTo(pageInput);
}
}).call(Example);
More information: Create or edit model-driven app web resources
Follow these steps to enable the Power Apps grid control as the main grid (table view) or within a model-driven form subgrid:
When you enable the Power Apps grid control, an Events tab appears. Select the Events tab:
- Under the Form Libraries section, add the Form Library from the web resource created.
- Under the Event Handlers section, select the event OnRecordSelect and select Add and a popup appears.
- 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.
More information: Power Apps grid control
Events (Client API reference)
Events in forms and grids in model-driven apps