Dataset PCF using FluentUI: open record

This is a part of my blog “My Checklist for a Dataset PCF using FluentUI“. What possibilities do we have to open a record and navigate to the form? I can think of three methods:

  1. using Navigation.openForm
  2. using Navigation.navigateTo – unsupported (for now?)
  3. using dataset.openDatasetItem

All of them will work only for the ModelDriven Apps. My favorite is the last one : dataset.openDatasetItem. But what’s the difference between them?

1. context.navigation.openForm

The context passed to the PCF (as parameter for updateView method), has a property named navigation, with some methods similar to the ModelDriven Apps SDK (Xrm.Navigation), and we can use the openForm method to navigate to a form:

    entityName: "orb_pcftester", 
    entityId: "27a3e4a0-7ad2-ea11-a812-000d3a23cb53"

The openForm has a few options like “openInNewWindow”, width, height, windowPositions which could have helped to open the record without leaving the grid, but unfortunately they didn’t work. The only option which worked for me (at least for the web client in ModelDriven Apps), was navigating away from the grid into the form, as a standard grid would do too.

2. context.navigation.navigateTo

This possibility is also provided by context: context.navigation.navigateTo. The method is similar to the new SDK method for ModelDriven Apps “Xrm.Navigation.navigateTo”, providing possibilities to open a Form/EntityList/WebResource by navigating away or as an inline Dialog.

It is possible to use it to open a form as a “modal” dialog, while the grid won’t be unloaded. So when the user closes the form, he/she won’t loose the grid state. But there are some problems with this:

  • It’s not documented in the pcf sdk, so it’s unuspported
  • Not sure it will always work, but my test worked
    entityName: "orb_pcftest"
}, {
    target: 2,  
    height: {value: 80, unit:"%"},
    width: {value: 70, unit:"%"}, 
    position: 1

3. Dataset.openDatasetItem

The methods above (Navigation ones) would have worked from a Field-PCF too, but the dataset.openDatasetItem possibility is provided by the dataset itself.

Dataset.openDatasetItem works similar with Navigation.openForm (1): it navigates away from the grid, but there is a small but interesting difference. In the sdk this is described as:

Open data-set item for a given EntityReference. It checks if there is a command with command button id Mscrm.OpenRecordItem. If exists, it executes the command, otherwise it just navigates to the associated form of the EntityReference.

Do you know the new possibility to override the behavior of “open record”: A use-case for this is shown by Andrew Butenko, in the blog about form switcher; there might be more use cases for it. So, if the customer has overridden the default command, we get this functionality out of the box without having to take care of anything.

Comparison of the possibilities

So the “dataset.openDatasetItem”(3) and openForm (1) are similar: the user leaves the grid, while navigateTo(2) can show a dialog containing the form without leaving the grid. What are the pros and cons of (1 & 3) vs (2).

If you choose the dialog option (2) using navigateTo:

😊 The grid will not be unloaded; the user will keep the grid state (page, sorting, selection, eventually even more)

😐 You need to refresh the grid data when the user closes the form, since the data might be changed on the form

If you choose the “openForm” (1) or openDatasetItem (3):

😣 The grid will be unloaded, so sorting & paging state will be lost.

😐In case you want to keep the state (paging, sorting), you can cache that using the pcf state (more details on caching can be found in my other blog).

😊 The data will be automatically refreshed by the runtime for you.

😊 But not everything will be lost: the text the user is searching on will stay, so the data is still filtered

(I’ve used the “Back” button introduced by Wave 2 2020; but Save&Close would have the same effect)

😣 Unfortunately, the searched-text won’t stay for subgrids.


That’s super easy: the DetailsList has a property called “onItemInvoked”. There we can register a callback calling dataset.openDatasetItem

That’s it.

One thought on “Dataset PCF using FluentUI: open record

Add yours

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Website Powered by

Up ↑

%d bloggers like this: