Search code examples
javascriptiframedynamics-crmdom-eventsdynamics-365

In Dynamics 365, is there a way to filter associated view results based on a record's field value and user permissions?


As the title states, I need to filter results of an associated view based on a record's field value and user permissions.

I've used some Javascript to achieve this whenever the iFrame loads, but if the user switches to a different view, my Javascript is not called and the filtered records come back. I've tried to implement an event listener for various changes within the iFrame, but haven't been able to get what I need. I've gotten onclick to call my function whenever the user opens the view dropdown, but I need it to call whenever they actually switch views.

Am I over complicating this and there's a native way to do this? Or does anyone know how to detect changes within an iFrame?


Solution

  • Unfortunately there’s no native config to do it by OOB. I recommend these.

    1. Don’t rely on associated view, as the name suggests it’s for seeing all the associated records. Remove navigation item in Form editor to remove them if you don’t want your users to see it
    2. Use Subgrid for all your different needs, but not with view switcher, as again you will get roadblock of view switch triggers, etc. also this is going to be unsupported approach to rig the FetchXml with your custom filters
    3. Custom HTML with grid is better or even PCF control of your own to take query & filters
    4. Plugin on RetrieveMultiple can be used in worst cases