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

Community site session details

Session Id :
Microsoft Dynamics 365 | Integration, Dataverse...
Suggested answer

Filter View by N:N Tag Selection from a Ribbon Dialog in Dynamics 365

(2) ShareShare
ReportReport
Posted on by 4

Hi everyone,

I'm working on a customization in Dynamics 365 CRM and could use some help with a tagging and filtering scenario.

Here’s the setup:

  • There's a custom button in the ribbon that opens a dialog window allowing users to select one or more tags.

  • Tags are a separate entity connected to the main records through an N:N relationship.

  • There's also a view displaying a list of these main records.
     

Goal:

When a user selects a tag from the dialog, I want to:

  1. Dynamically filter the records in the current view to show only those that are linked to the selected tag.

  2. Optionally, display the selected tag somewhere in the view (for visual context).

Has anyone implemented something similar or can suggest an approach to dynamically apply a filter to a view based on tag selection from a custom dialog?

Any advice, ideas, or examples would be greatly appreciated!

Categories:
I have the same question (0)
  • Suggested answer
    DAnny3211 Profile Picture
    11,369 on at
    Filter View by N:N Tag Selection from a Ribbon Dialog in Dynamics 365

    Hi,

     

    To dynamically filter a view in Dynamics 365 CRM based on N:N tag selection from a ribbon dialog, you’ll need to combine JavaScript customization, Ribbon Workbench, and Web API calls. Here's a recommended approach based on best practices and community solutions:

     
     

    1. Use Ribbon Workbench to Trigger Custom Dialog

     

    • Create a custom ribbon button that opens a dialog for tag selection.

    • Use Ribbon Workbench to configure the button and pass context parameters (e.g., record ID, entity name).


    •  
     
     

    2. Capture Selected Tags in Dialog

     

    • In the dialog, allow users to select one or more tags (from the N:N related entity).

    • Store selected tag IDs temporarily (e.g., in session or a hidden field).


    •  
     
     

    3. Apply Filter to View Using JavaScript

     

    • Use a custom JavaScript function to filter the view based on selected tags.

    • You can use the Xrm.WebApi.retrieveMultipleRecords method to fetch records linked to the selected tags and then refresh the grid with those records.


    •  
     

    Example logic:

     

     

    function filterRecordsByTags(selectedTagIds) {
        // Build FetchXML or Web API query to get records linked to selected tags
        // Update the subgrid or view with filtered results
    }
    

     

     
     

    4. Use Supported N:N Filtering Techniques

       
     

    5. Customize Subgrid Behavior

     

    • If you're using a subgrid to display related records, override the Add Existing button behavior using Ribbon Workbench and your custom script [3].

    • This allows you to control which records appear based on tag selection.


    •  
     
     

    Optional: Display Selected Tags in View

     

    • You can use a custom field or notification banner to show selected tags for context.

    • Alternatively, use a custom control or PCF component to enhance the UI.


    •  
     
     

    Please verify if this approach aligns with your scenario or if you'd like help implementing specific parts of the solution.

     

    Thanks and best regards,\
    Daniele\
    Note: This response was prepared with support from Copilot to ensure clarity and completeness.

     

    [2]: https://www.itaintboring.com/dynamics-crm/filtered-nn-lookup/\
    [3]: https://xrmdynamicscrm.wordpress.com/2020/06/07/dynamics-365-sub-grid-add-existing-look-up-view-nn/\
    [1]: https://blog.magnetismsolutions.com/blog/paulnieuwelaar/2018/05/17/filter-n-n-add-existing-lookup-dynamics-365-v9-supported-code


    References

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…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

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

#1
Sahan Hasitha Profile Picture

Sahan Hasitha 394

#2
Nimsara Jayathilaka. Profile Picture

Nimsara Jayathilaka. 123

#3
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 102 Super User 2025 Season 2

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans