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 :
Finance | Project Operations, Human Resources, ...
Answered

How to Disable Manual Entry on a Form grid field and Only Choose From a LookUp List?

(0) ShareShare
ReportReport
Posted on by 1,019

Hello community!

I'm trying to make a field in a form grid to be only filled with a list look up options and not be able to enter values manually and let the user type whatever data he wants.

I want to force him to use the look up list.

How can I achieve that?

I made the look up list by overriding the lookup method of the form field control method.

Thanks in advance!

I have the same question (0)
  • Sergei Minozhenko Profile Picture
    23,093 on at
    RE: How to Disable Manual Entry on a Form grid field and Only Choose From a LookUp List?

    Hi Momochi,

    I'm not sure if it's a good idea to disable this feature as it's quite useful in case if you already know the value and you don't need to search in the lookup and even to open lookup. Maybe you should think about proper validation of input value in validateField method.

  • Suggested answer
    Anton Venter Profile Picture
    20,301 Super User 2025 Season 2 on at
    RE: How to Disable Manual Entry on a Form grid field and Only Choose From a LookUp List?

    Hi Momochi,

    If the field in question is in a custom table, the best practice way to ensure that no other values can entered in forms is to define a relation on the field to the other table.

    If the field in quesion is a standard field, then this should be possible with the "Lookup Only" property of the field control. I have not tried it myself.

    c_2D00_Screenshot-2021_2D00_01_2D00_25-181128.jpg

  • Momochi Profile Picture
    1,019 on at
    RE: How to Disable Manual Entry on a Form grid field and Only Choose From a LookUp List?

    Hello Sergei,

    is Using ValidateField will thorw the error after trying to save the record?

  • Sergei Minozhenko Profile Picture
    23,093 on at
    RE: How to Disable Manual Entry on a Form grid field and Only Choose From a LookUp List?

    Hi Momochi,

    ValidateField is executed when value is changed for the field and users will see the error before they save the record or leave the field.

  • Momochi Profile Picture
    1,019 on at
    RE: How to Disable Manual Entry on a Form grid field and Only Choose From a LookUp List?

    Hello Anton,

    It's a custom form with custom tables. But Since I'm working on a different module, will it work if I defined a new relation for the table in another module using extension? or this is not a good practice.

    Thanks for the tips.

  • Momochi Profile Picture
    1,019 on at
    RE: How to Disable Manual Entry on a Form grid field and Only Choose From a LookUp List?

    Hello Sergei,

    I'm sorry I'm new in this area....

    I see it's a table event.

    Which line of code should I use to throw an error after checking the value?

    Thanks.

  • Sergei Minozhenko Profile Picture
    23,093 on at
    RE: How to Disable Manual Entry on a Form grid field and Only Choose From a LookUp List?

    Hi Momochi,

    I think you need to decide first where to apply the change: your model or model where table was created. Event handlers, extensions and CoC increase complexity of the code.

    Here is one one of the example how to use event handlers, but the idea is the same for direct method change on the table or CoC method.

    d365solution.blogspot.com/.../how-to-write-validatefield-method-in.html

    Also, you can use validate methods on the form if you want to restrict validate logic only for one form.

  • Momochi Profile Picture
    1,019 on at
    RE: How to Disable Manual Entry on a Form grid field and Only Choose From a LookUp List?

    Hi Sergei,

    Thanks for the info!

    Yes, I would like it to be on a specific form only.

    I see there are two methods for validation: onValidated and onValidating.

    I'm totally confused actually on what's the difference and which one should I use...

    and about the example you posted, if I wanted to throw an error I should use args.setReturnValue(false)?

    I'm sorry for taking your time.

    Thanks.

  • Momochi Profile Picture
    1,019 on at
    RE: How to Disable Manual Entry on a Form grid field and Only Choose From a LookUp List?

    I tried using both OnValidating and onValidated events, and I used checkFailed() method to throw the error as shown in the example you posted.

    But once the warning sign is shown on the field, it won't go even if I posted correct data again...

    Screenshot:

    pastedimage1611613079340v1.png

    is something wrong with how I checked the value?

  • Momochi Profile Picture
    1,019 on at
    RE: How to Disable Manual Entry on a Form grid field and Only Choose From a LookUp List?

    after running the debugger it seems that sender.formRun().dataSource("datasource").cursor(); didn't get the value entered.... it shows as null, though it has taken the other previous fields.

    EDIT: the debugger shows that it's stuck with the first value entered and always checks using first value entered no matter how many times I change it

    Both onValidated and onValidating fires before they take the new selection from the look up...

    So should I look for other events?

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 > Finance | Project Operations, Human Resources, AX, GP, SL

#1
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 1,964

#2
André Arnaud de Calavon Profile Picture

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

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 564 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans