Table OnLookup

Time to revisit. I’ve been working with Navision for 5+ years now, and for the life of me, I can’t figure out why I can’t get this to work. The version of Attain I am working with is v3.60. I have a table, with a field that has an OnLookup trigger defined to get the Vendor No. out of the Vendor table based on a couple of conditions. Here is the code from the OnLookup trigger of the table: Vendor.RESET; Vendor.SETCURRENTKEY("Vendor Posting Group"); Vendor.SETRANGE("Vendor Posting Group",GlobalSetup."Therapist Vdr. Posting Grp."); Vendor.SETRANGE(Property,Property); CLEAR(FormVendorList); FormVendorList.SETTABLEVIEW(Vendor); FormVendorList.LOOKUPMODE(TRUE); IF FormVendorList.RUNMODAL = ACTION::LookupOK THEN BEGIN FormVendorList.GETRECORD(Vendor); MESSAGE('Vendor No. returned: %1', Vendor."No."); VALIDATE("Therapist code",Vendor."No."); END; Vendor is a Record (Vendor) GlobalSetup is a custom table we have. FormVendorList is a Form Variable to the Vendor List Form Initially, I wanted to just define a Table Relationship for this field, but since we only want vendors that match the Vendor Posting Group defined in our GlobalSetup table, I cannot use the Table Relationship functionality. I decided to do the OnLookup code instead. When I run the table, and perform the OnLookup, I get my message box telling me what value I selected from within the Vendor List, but the value NEVER gets assigned to the table. I have tried a direct assignment (“Therapist Code” := Vendor.“No.”) and the current VALIDATE assignment, and the value never gets validated. Am I missing anything? Thank you for looking at this. Robert Ellsworth Watts Up Inc.

The situation is that the OnLookup trigger of a table will execute as expected when it is executed from a FROM, updating the current record in the form. When executed by running the TABLE and doing the lookup, the current record in the table is NOT updated. This is a bug in 3.60 and 3.70, and possibly 3.10. I am not sure when this crept in but it has not always been that way. If you have a situation where running it from a FORM is not working, then please report this.

This is a feature of 3.xx. Bit of a nightmare in fact. You can’t modify the current record from the Validate Trigger in the Table designer. You could write code to get around it (reccopy.get; then reccopy.modify;). But now a days, I just create a form with the wizzard, and do it from there. ____________________________________ Sorry, I didn’t realize there was a page 2 here and that you worked it out.

I meant from a FORM of course, not a FROM. :slight_smile: And defnitely not from a TABEL. :slight_smile:

You can receive runtime errors. OnLookup trigger of the form: Vendor.RESET; Vendor.SETCURRENTKEY(“Vendor Posting Group”); Vendor.SETRANGE(“Vendor Posting Group”,GlobalSetup.“Therapist Vdr. Posting Grp.”); Vendor.SETRANGE(Property,Property); IF FORM.RUNMODAL(0, vendor) <> ACTION::LookupOK THEN EXIT(FALSE); TEXT := Vendor.“No.”; EXIT(TRUE); //autovalidate (including form trigger)