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 :
Customer experience | Sales, Customer Insights,...
Answered

onChange of an optionset apply presearch on a lookup field

(0) ShareShare
ReportReport
Posted on by 903

Hello,

In a form i have an option set that has two options (Type A and Type B), and a lookup field.

OnChange of the option set, I would like to apply a presearch or addCustomFilter to only show the data that are based on the type that is selected from the option set.

Could you please point me in the right direction to achieve this kind of requirement?

I would highly appreciate if you could provide a very small sample code on how it can be done.

Any help is greatly appreciated.

Best regards,
EBMRay

I have the same question (0)
  • Suggested answer
    Abdul Wahab Profile Picture
    12,119 Moderator on at
    RE: onChange of an optionset apply presearch on a lookup field

    Hi EBMRay.

    My suggestion is to avoid code. Convert option set into a lookup because we have a filtering option available between two dependent tables.

  • Suggested answer
    Abdul Wahab Profile Picture
    12,119 Moderator on at
  • EBMRay Profile Picture
    903 on at
    RE: onChange of an optionset apply presearch on a lookup field

    Hello Abdul Wahab ,

    Thank you for providing those helpful documentations.

    The reason I am using options set instead of lookup is to avoid the user keep changing the label title and to always have a static value that you can rely on in your code.

    Because using lookups he can at any time rename type A to type Z and that might affect any filtering logic that you might have (Plugins, JS, a workflow...)

    What do you suggest in that case?

    Awaiting your response.

    Best regards,

    EBMRay

  • Verified answer
    Abdul Wahab Profile Picture
    12,119 Moderator on at
    RE: onChange of an optionset apply presearch on a lookup field

    Hi EBMRay,

    There is no doubt you are using the most effortless way. 

    1. "to avoid the user keep changing the label title and to always have a static value that you can rely on in your code."
      1. You can prevent updates using security roles similarly prevented in the option sets.
      2. You have a record GUID similar to a value for the option set.
      3. I am referring to the low now code. When you use lookup by replacing the 'option set'. You can filter the records on a model-driven app with a configuration... It will also help you maintain dependencies...
      4. pastedimage1669271442837v1.png
    2. "Because using lookups he can at any time rename type A to type Z and that might affect any filtering logic that you might have (Plugins, JS, a workflow...)"
      1. I do not think there is a still need to answer this...

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 > Customer experience | Sales, Customer Insights, CRM

#1
Rishabh Kanaskar Profile Picture

Rishabh Kanaskar 241

#2
Tom_Gioielli Profile Picture

Tom_Gioielli 164 Super User 2025 Season 2

#3
MVP-Daniyal Khaleel Profile Picture

MVP-Daniyal Khaleel 153

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans