NetTalk Central

Author Topic: Popup Lookup Browse - Best Practice  (Read 3210 times)

Neil Porter

  • Jr. Member
  • **
  • Posts: 88
    • View Profile
    • Email
Popup Lookup Browse - Best Practice
« on: June 07, 2013, 01:14:14 PM »
I'm trying to do something slightly out of the ordinary with a lookup, and I'm getting some strange results. I've spent so much time trying different things now, that I've got myself all confused, so I thought I'd post here to check that I'm not going about it all wrong.

I have a number of forms where the user has to populate a postal address (Addr1, addr2 , town, postal code, etc.). I would like to allow the user to enter certain known bits of the address, and then press a lookup button. I would then like to display a browse with various address lines that match the keyed criteria, that they could select, which would populate on the original form.

I would like to fill my lookup browse manually, using an SQL query or some address lookup software and a temporary table filtered by session ID. The idea being that I can run an sql query to see if they've ever used the address before,  in which case use it, or failing that, use the address lookup software to give them some options. Once the lookup has completed, I can clear down the temporary table.

I've sort of got this working, by attaching a lookup button to one of the fields on the form (postcode/zipcode), but after selecting my record from the lookup browse, I get random text appearing in the original form field. I'm also not convinced that I'm managing to pass the key entered data to my lookup correctly for my SQL query. Using Stop messages, my sqlquery seems to be firing at some funny times, without it having any data to use for the where clause.

I've also noticed that the lookup seems to behave differently if I have it as a popup. In popup mode one field in the form gets populated from the lookup. If not in popup mode, all of the other address fields get populated too (Which is what I want).

So my questions are:

1) Do I use a lookup button attached to one of the fields on my form, or should I create a separate button to call my lookup?
2) How do I make sure that all of my address variables on my form are passed to the lookup browse, and how to I get them back again (the FileToSessionQueue doesn't seem to work in this case)
3) Which Embed should I use to call my SQL in the Lookup browse? I've tried "Start of Procedure" and "Call Browse" so far.

Any suggestions would be very welcome.

Regards,

Neil.
Clarion 11.0.13244
NetTalk 11.04

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11251
    • View Profile
Re: Popup Lookup Browse - Best Practice
« Reply #1 on: June 09, 2013, 09:14:53 PM »
>> Using Stop messages,
Stop is very bad in the web context because it affects timing. Do not use Stop. Use

p_web._trace('whatever')

and run Debugview on the machine (the server machine) to see the text.

>> I've also noticed that the lookup seems to behave differently if I have it as a popup. In popup mode one field in the form gets populated from the lookup. If not in popup mode, all of the other address fields get populated too (Which is what I want).

which build are you using?

>> 1) Do I use a lookup button attached to one of the fields on my form, or should I create a separate button to call my lookup?

it can probably work either way. But it sounds to me like possible the latter approach might be better, because you're not really doing a lookup. At least not in the "related table" sense. But it's really hard to be sure - there are a number of factors involved.

<< 2) How do I make sure that all of my address variables on my form are passed to the lookup browse, and how to I get them back again (the FileToSessionQueue doesn't seem to work in this case)

impossible to say without an example. Normally the other address variables would already be in the session queue - as they are completed they are stored there. So you certainly shouldn't do a FileToSessionQueue (because that would overwrite them). So yeah, you don't "pass" the fields to the lookup - they're already in the session q.

>> 3) Which Embed should I use to call my SQL in the Lookup browse? I've tried "Start of Procedure" and "Call Browse" so far.

right click on the procedure, choose "view source" and take a look at the code. my guess is you want to populate the memory table right before the browse reads the data out the memory table. Search the generated code for LOOP and you should be in the right place.

cheers
Bruce




Neil Porter

  • Jr. Member
  • **
  • Posts: 88
    • View Profile
    • Email
Re: Popup Lookup Browse - Best Practice
« Reply #2 on: June 10, 2013, 11:36:29 AM »
OK Bruce, _Trace rather than Stop, it is from now on.

I like the idea of my own button to call the lookup, but that in itself raises it's own question. How do I call a browse in "Select" mode from my own button? If I don't call the popup as a select, my select button(s) don't appear. Am I better having my own select button on the lookup browse which isn't really a "Select" button, but is actually an "Other" button? If that is the case how do I ensure that my lookup browse closes and returns to the parent, with the currently selected record stored in the session queue, and where would I embed code in my parent form to update the form fields from my lookup (After Lookup, seems obvious???)

My SQL in the lookup browse seems to work well embedded  just above the file loop as you suggested, thank you.

Sorry to bombard you with quite a few questions out of the blue. My NT webservers  haven't had much attention for a while, and they are in need of a bit of love. I'm taking the opportunity to try and understand what you are doing under the hood, rather than just blindly using the templates.

Regards,

Neil.


Clarion 11.0.13244
NetTalk 11.04

estadok

  • Jr. Member
  • **
  • Posts: 84
    • View Profile
    • EstaSoft
    • Email
Re: Popup Lookup Browse - Best Practice
« Reply #3 on: June 10, 2013, 01:23:41 PM »
Hi Neil!

In my app I use custom button for popup lookup for select adres from regional adress book (1 415 000 recs). I use browse inside a memory form and trigger on a save button (select). In parent (GotFocusBack) I check this trigger:
IF p_web.GSV('glo:SomeWhat') = 1
    SomeTable{prop:sql} = 'select * from sometable where SomeID = '&p_web.GSV('YourValueFromChild')
    NEXT(SomeTable)
    ! do something
END
   p_web.SSV('glo:SomeWhat',0) ! or p_web.DeleteSessionValue('glo:SomeWhat')

And all works great! I use this method for autofill forms from "templates".
Clarion 9.0.10376
NetTalk 7.26
SecWin 6.25
StringTheory 1.92

Neil Porter

  • Jr. Member
  • **
  • Posts: 88
    • View Profile
    • Email
Re: Popup Lookup Browse - Best Practice
« Reply #4 on: June 11, 2013, 05:35:51 AM »
Hi Alexandr,

That works perfectly for me!

Thank you very much.

Regards,

Neil.
« Last Edit: June 11, 2013, 12:28:38 PM by Neil Porter »
Clarion 11.0.13244
NetTalk 11.04