NetTalk Central

Author Topic: Lookup  (Read 3486 times)

kevin plummer

  • Hero Member
  • *****
  • Posts: 1195
    • View Profile
    • Production Accounting and Software Payroll
Lookup
« on: July 17, 2007, 07:42:09 PM »
I want to be able to lookup a Supplier list based on the currency and the supplier name the user has entered.

I tracked this line of code down...

        packet = clip(packet) & p_web.CreateStdButton('submit',Net:Web:LookupButton,loc:formname,p_web._MakeURL(clip('LookupVendor')&'?file=VENDOR&LookupField=L:VendorName&Tab=3&ForeignField=VEN:NAME'),'right_fram')


Can I pass more than parameter so it restricts the list to just suppliers from one Currency and lands on the right supplier?
or should I just set a session variable and use this in the lookup filter?
In the lookup screen is the filter done before it tries to match the filed?
If not what will happen if it lands on a supplier that is then filtered away?

Cheers,

Kevin

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11191
    • View Profile
Re: Lookup
« Reply #1 on: August 01, 2007, 04:06:06 AM »
One part of the question is simple, the other is actually quite complex.

First the simple bit - the filter. Filters are easy enough to do on the browse, use a conditional filter. Use a session variable, set (presumably) by a form field on the calling form. (set session value using simple "send new value to server".)

Now your "jump into lookup near closest record" gets a tad complicated. Because in the form field you're allowing them to type either the code, or the first part of the description. If I type 11 should I jump into the lookup near code "110" or near description "11 East Boulevard"?

One approach is to test it first to see if it is a complete, valid, code. If it is jump there, if not jump to the nearest "description". I haven't worked out the kinks in this approach yet though.

Aside: Incidentally in 4.29 I've added a field to the lookup so that you can specify the sort oder for the lookup procedure.

cheers
Bruce

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11191
    • View Profile
Re: Lookup
« Reply #2 on: August 01, 2007, 06:35:51 AM »
Ok, here's an update.

In version 4.29 the browse-when-called-as-a-lookup is a bit smarter when the Form Field already contains something.

a) It starts by assuming the form field already contains a valid value. If so it jumps to this record (regardless of the browse's sort order). the browse sort order is explicitly set by the Form Field Lookup settings.

b) If that fails (ie the code is not valid) then it assumes the form field contains what can be thought of as a "locator". The sort order specified by the Form Field Lookup settings is applied and the browse "jumps" to the nearest position to the current Form Field value.

c) If you wish to add even smarter code, a good place to do it is the embed point, in the browse, called "After Setting Browse Behavior Settings". To jump to the record of your choice do whatever you need to do and finish with
p_web.SetValue('fil:id',fil:id)
where fil:id is the unique identifier for the browse (ie component of unique, unchanging key) and where it contains the value you want to jump to.

Cheers
Bruce

mriffey

  • Newbie
  • *
  • Posts: 43
    • View Profile
    • Email
Re: Lookup
« Reply #3 on: August 29, 2007, 10:23:42 AM »
One scenario where this becomes complex is when the table has a unique unchanging sysid that isnt displayed.

Perhaps the make of a vehicle is "Porsche" but the unique unchanging id for that table is a long. The form field is a long (perhaps hidden or read only or something) and the make text is displayed but unkeyable (maybe as a comment).

If the lookup button takes you to a browse where the list of makes is sorted by name:

PONTIAC
PORSCHE
RENAULT

The returned value should be the long that is associated with PORSCHE (or whatever) - likely, the long is a hot field for this reason.

How does this locator code work in this kind of circumstance? (one common to the win32 clarion world, of course)

Mark