Lookup forms that allow/disallow editing

bhalpinbhalpin Member Posts: 309
Hi.

I had occasion to add the Item."Item Category Code" field to a form, and gotthe expected lookup behaviour for free. But, when the form Item Categories pops up, you can edit the contents, which is (in this case) undesirable. I looked for missing 'magic' in the table and form, but all looked normal. So I checked a few others, like the lookups from the item card fo posting groups, unit of measure. All allowed editing. (I gues I never really noticed before ...)

Anyway, the user wants the category lookup to behave like the item no. on a sale order line, the sell-to customer in the header, etc., etc., - they are all "pure lookups", with no editing.

This was all in 4.0SP3, and I've checked up to 6.0SP1 and it's still the same.

So this boils down to two questions:

1 - Is there a reason they made some lookups "pure" lookups and others are editable? (I mean from an user-inteface design point of view, not a technical one.)

2 - Regardless, am I going to have to hand-code the lookup and set the form to Editable(False) to get the desired behaviour?

I guess there's a 3rd question - where is the "magic" that makes the forms behave differently?

Thanks a bunch!

Comments

  • DenSterDenSter Member Posts: 8,305
    1 - there's two kinds of list forms. The first is a list form for master tables and other tables that you have a 'Card' form for. In those cases you edit the records in the 'Card' form, and the list form should never be editable. Non-editable list forms should always be called "Something List", like "Item List" or "Customer List". The second is a list form that is used for both data entry and selection. In this case, there is no 'Card' form, because the number of fields is usually small enough to be contained on the list form. These list forms are always editable, and are recognized by their name, which is the table name in plural, such as "Default Dimensions", or "Purchase Prices".

    2 - There's a property called 'LOOKUPMODE', which you can set if you use a form as a variable. I think you might be able to catch it in OnOpen (you know... IF LOOKUPMODE THEN CurrForm.EDITABLE := FALSE, or CurrForm.EDITABLE(NOT LOOKUPMODE) or something like that). I don't have NAV open so I can't check at the moment, but if I remember I'll see if I can find it for you.
  • matttraxmatttrax Member Posts: 2,309
    DenSter wrote:
    IF LOOKUPMODE THEN CurrForm.EDITABLE := FALSE

    I think it's
    IF CurrForm.LOOKUPMODE THEN
      CurrForm.EDITABLE := FALSE;
    

    in the OnOpenForm trigger.
  • bhalpinbhalpin Member Posts: 309
    Thanks guys.

    I can 'hack' it from here.

    It's funny that base NAV doesn't have the IF LOOKUPMODE stuff in there already.

    Cheers!
  • DenSterDenSter Member Posts: 8,305
    bhalpin wrote:
    It's funny that base NAV doesn't have the IF LOOKUPMODE stuff in there already.
    I've always wondered why forms in lookup mode are editable by default, that never made sense to me. This way you are able to add/maintain records on the fly, but in my opinion that's a different function. I guess the designers had a different opinion :mrgreen:
  • matttraxmatttrax Member Posts: 2,309
    Same here. I always thought that if you wanted to add something you should be going through a setup of some kind. Has never made sense to me.
  • bhalpinbhalpin Member Posts: 309
    Maybe they expect you to manage the edit vs. lookup through table permissions.
  • ShedmanShedman Member Posts: 194
    matttrax wrote:
    DenSter wrote:
    IF LOOKUPMODE THEN CurrForm.EDITABLE := FALSE

    I think it's
    IF CurrForm.LOOKUPMODE THEN
      CurrForm.EDITABLE := FALSE;
    

    in the OnOpenForm trigger.
    If it's a boolean just use it as a boolean :wink:
    CurrForm.EDITABLE(NOT CurrForm.LOOKUPMODE);
    
  • bhalpinbhalpin Member Posts: 309
    Like: CurrForm.EDITABLE(NOT CurrForm.LOOKUPMODE); ?
  • DenSterDenSter Member Posts: 8,305
    You mean what I said in my first reply:
    DenSter wrote:
    2 - There's a property called 'LOOKUPMODE', which you can set if you use a form as a variable. I think you might be able to catch it in OnOpen (you know... IF LOOKUPMODE THEN CurrForm.EDITABLE := FALSE, or CurrForm.EDITABLE(NOT LOOKUPMODE) or something like that). I don't have NAV open so I can't check at the moment, but if I remember I'll see if I can find it for you.
    :mrgreen:
  • matttraxmatttrax Member Posts: 2,309
    Shedman wrote:
    If it's a boolean just use it as a boolean :wink:
    Code: Select all
    CurrForm.EDITABLE(NOT CurrForm.LOOKUPMODE);

    I could be mistaken, but I believe that that is not correct according to NAV coding standards. If you want to assign a value you are supposed to use := or VALIDATE. I'll be the first to admit, though, that I still sometimes do it that way. Old habits die hard.
  • David_SingletonDavid_Singleton Member Posts: 5,479
    I add this code for most of my clients. I think it is definitely an inconstancy and not explained, but one of those things we just know.



    Form - OnOpenForm()
    // don't allow editing of this form in, lookup mode
    IF CurrForm.LOOKUPMODE THEN
    CurrForm.EDITABLE(FALSE);
    David Singleton
  • David_SingletonDavid_Singleton Member Posts: 5,479
    Sorry had this open for a loooonnngg time and just replied. It looks like we all agree on this.
    Shedman wrote:
    IF CurrForm.LOOKUPMODE THEN
      CurrForm.EDITABLE := FALSE;
    

    If it's a boolean just use it as a boolean :wink:
    CurrForm.EDITABLE(NOT CurrForm.LOOKUPMODE);
    

    These are actually very different pieces of code that do different things; they are not the same. :mrgreen:
    David Singleton
  • zacrzacr Member Posts: 19
    Extending this topic a little more, I have a situation where I want to use one form for both data entry as well as displaying the drill-down results of a FlowField. For data entry, this form is used as a subform and should be editable. When looking at the FlowField, which is in a completely different table, i want to be able to drill down and see the entries in a non-editable state.

    The only solution I've been able to come up with is to have two identical forms except the subform is editable and the drill-down is not.

    Any other ideas?

    Thanks in advance!

    - Zac
  • AndwianAndwian Member Posts: 627
    Shedman wrote:
    IF CurrForm.LOOKUPMODE THEN
      CurrForm.EDITABLE := FALSE;
    

    If it's a boolean just use it as a boolean :wink:
    CurrForm.EDITABLE(NOT CurrForm.LOOKUPMODE);
    

    These are actually very different pieces of code that do different things; they are not the same. :mrgreen:

    What is the differences?
    Regards,
    Andwian
  • TonyHTonyH Member Posts: 223
    Because you change the state of "editable" regardless of any logic. It will always be set one way or the other...

    t
Sign In or Register to comment.