web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics 365 | Integration, Dataverse...
Unanswered

Dynamically set filters on editable grids in Dynamics 365 9.1 Unified Interface

(0) ShareShare
ReportReport
Posted on by 30

Is it possible to dynamically set a filter on an editable grid from within a control event handler in the current version of Dynamics 365 Unified Interface?

I want to dynamically set a filter on an editable grid with JavaScript on Dynamics 365 9.1 Unified Interface. In this case the user selects a row from the first grid, and matching records get listed in the second grid.

There are many articles and forums about setting a filter using JS and FetchXML. They mainly use one of the 3 methods to access a grid for setting a filter.

1. Using: executionContext.getFormContext().getControl("...")

This is the supported way to access an element. However, getFormContext returns gridRowContext when called from a grid event. I was unable to access the form and the other grid this way.

2. Using: Xrm.Page.getControl("...").getGrid()

This is the deprecated method to access an element. But this way we can access another control from a triggered event, working around the issue in the 1st method. However, when accessed this way, the control doesn't give us the SetParameter method which is required to set the filter.

3. Using: window.parent.document.getElementById("...")

This is the worst, unsupported way to access an element. However, this was apparently the last resort before the Unified Interface. In the current version I naturally can't access the grid this way as the system holds controls differently, within IFrames.

I'll try keeping a global reference to the control in the Form.onLoad event, but this may not work or bring other issues.

I have the same question (0)
  • LeoAlt Profile Picture
    16,331 Moderator on at

    Hi partner,

    1.About using "executionContext", you could trigger this method in form onload event to get the formContext. And then use other functions.

    You could refer to this doc for more details about grid control.

    pastedimage1576808845113v1.png

    https://docs.microsoft.com/en-us/powerapps/developer/model-driven-apps/clientapi/reference/grids

    2.We do not suggest you to use Xrm.Page to get attribute or control in UCI cause it will not be supported in UCI in the future.

    3.Original JS method is no supported in Dynamics 365 form.

    Best Regards,

    Leo

  • DeadDuck Profile Picture
    30 on at

    Thank you Leo. The problem is I need the formContext when a select event gets triggered, instead of formLoad. Perhaps the form context can be saved globally on form load and used later in the event, but the state will be changed so I'm not sure if it would work without issues.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Microsoft Dynamics 365 | Integration, Dataverse, and general topics

#1
#ManoVerse Profile Picture

#ManoVerse 93

#1
Siv Sagar Profile Picture

Siv Sagar 93 Super User 2025 Season 2

#3
Martin Dráb Profile Picture

Martin Dráb 62 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans