# Table OnLookup

**URL:** <https://www.dynamicsuser.net/t/table-onlookup/6448>\
**Category:** Developers Forum\
**Created:** [October 29, 2002, 1:21pm UTC](https://www.dynamicsuser.net/t/table-onlookup/6448 "2002-10-29T13:21:32Z")\
**Posts on this page:** 5\
**Page:** 2

<div class="post-metadata">

**Author:** ![Robert\_Ellsworth](https://avatars.discourse-cdn.com/v4/letter/r/cdc98d/32.png) [@Robert\_Ellsworth](https://www.dynamicsuser.net/u/Robert_Ellsworth)\
**Post date:** [September 12, 2003, 5:06pm UTC](https://www.dynamicsuser.net/t/table-onlookup/6448/21 "2003-09-12T17:06:06Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![robertc](https://avatars.discourse-cdn.com/v4/letter/r/da6949/32.png) [@robertc](https://www.dynamicsuser.net/u/robertc)\
**Post date:** [September 12, 2003, 7:18pm UTC](https://www.dynamicsuser.net/t/table-onlookup/6448/22 "2003-09-12T19:18:45Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![David\_Singleton](https://sea1.discourse-cdn.com/flex023/user_avatar/www.dynamicsuser.net/david_singleton/32/7471_2.png) [@David\_Singleton](https://www.dynamicsuser.net/u/David_Singleton)\
**Post date:** [September 13, 2003, 5:08pm UTC](https://www.dynamicsuser.net/t/table-onlookup/6448/23 "2003-09-13T17:08:35Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![robertc](https://avatars.discourse-cdn.com/v4/letter/r/da6949/32.png) [@robertc](https://www.dynamicsuser.net/u/robertc)\
**Post date:** [September 14, 2003, 7:14pm UTC](https://www.dynamicsuser.net/t/table-onlookup/6448/24 "2003-09-14T19:14:28Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![AGUSTI](https://avatars.discourse-cdn.com/v4/letter/a/a8b319/32.png) [@AGUSTI](https://www.dynamicsuser.net/u/AGUSTI)\
**Post date:** [September 15, 2003, 7:28pm UTC](https://www.dynamicsuser.net/t/table-onlookup/6448/25 "2003-09-15T19:28:28Z")

</div>

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)

[Previous page](https://www.dynamicsuser.net/t/table-onlookup/6448.md?page=1)
