This article explains how to customize your Dynamics 365 form by filtering the ownerid lookup field. The goal is to display only system users where the custom boolean field dsl_driver is set to true. This ensures that only qualified users are selectable in the lookup, enhancing data integrity and user experience.
How It Works
The solution involves two key functions:
- filterOwnerLookup – Attaches a pre-search event to the ownerid lookup field.
- addOwnerLookupFilter – Adds a custom filter (using FetchXML) to restrict the lookup results.
When the form loads, the filterOwnerLookup function adds a pre-search event. Every time the lookup is opened, the addOwnerLookupFilter function runs and applies the filter, ensuring only system users with dsl_driver set to true appear.
Code Example
Below is the complete JavaScript code sample. Follow the provided usage instructions to integrate this into your Dynamics 365 environment.
Integration Steps
Create a Web Resource:
Save the above code as a JavaScript Web Resource in your Dynamics 365 instance.Attach to Form OnLoad:
In the form editor, add the JavaScript Web Resource and attach the filterOwnerLookup function to the form's OnLoad event.Publish:
Save and publish your customizations. Now, when the form loads and the ownerid lookup is used, it will display only the system users where dsl_driver equals true.
This customization is particularly useful in scenarios where user roles are restricted or when filtering based on specific criteria is necessary for process integrity. Enjoy a cleaner, more focused lookup experience in your Dynamics 365 forms!
No comments:
Post a Comment