NetTalk Central

Author Topic: Field Lookup problem  (Read 8219 times)

Keith

  • Sr. Member
  • ****
  • Posts: 306
    • View Profile
    • Email
Field Lookup problem
« on: July 22, 2015, 01:29:41 AM »
Hi

I have 3 different forms on which I have a District field which is populated by a Lookup on the Districts table which has two fields - Country and District Name. 

In the browse of District which is used for the selection I have code which filters the display viz:

      if upper(p_web.GSV('FND:Country')) not= Dis:Country then CYCLE.     

which means that if the country is Australia then Australian states are shown but if United Kingdom then a list of Counties is shown.

I have completed the Lookup template identically for the 3 forms (see picture' Lookup').  The Value field is a single component primary key.  There is no table relationship between the form (Resorts) and the lookup (districts).

One form is a standard browse/form situation where the form can be updated or a new record inserted and in both cases the lookup populates the receiving field.

Another form is called directly in 'Change' mode (no browse) and again, the lookup works perfectly.

The third form is called directly in 'Insert' mode and fails to populate the field on the first try.  The correct Districts display but after selection the field remains blank.  If you immediately try the lookup again there are no districts displayed.   If you then change the Country (and therefore the selection criteria) and redo the lookup it works and seems to work thereafter (at least for a few tries).

Any ideas on why this would be happening in this particular case.

Thanks

Keith



[attachment deleted by admin]
Clarion 10.0.0 build 12799
NetTalk 9.31
StringTheory 2.65
InsightGraphing 2.27

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11251
    • View Profile
Re: Field Lookup problem
« Reply #1 on: July 22, 2015, 03:22:17 AM »
example would be needed to be sure, but my guess is that the Filter is set wrong. But it's just a guess.

Bruce

Keith

  • Sr. Member
  • ****
  • Posts: 306
    • View Profile
    • Email
Re: Field Lookup problem
« Reply #2 on: July 23, 2015, 01:58:32 AM »
Hi Bruce

An example application is attached - PMTest1.zip and PMTest2.zip

The files in these zips need to be distributed as follows:

In c:\PetMotel put the content of PMTest2.zip.

In another folder put the app, dct and control.tps from PMTest1.zip

If you can't put the PetMotel folder in c: then whichever drive you use you will have to modify the record in COntrol.tps to reflect that drive (the field with 'C:\Petmotel in it).


You can access the program via: http://127.0.0.1:48040

Login with CONTROL/Keith/Keith and you will see the menus.  Contract 'FindaPet' and then expand and you will see the squishing.

If you choose the Menu Item 'Resort Records' and 'Change' a record and do a lookup on the 'region' field you will see a lookup which works.

If you then access with http://127.0.0.1:48040/?fpnew=yes you will get a menu item 'New Client'.  Click and do a lookup on the 'Region' field and you should see the selection browse but after you select something the Region field will not populate.  If you do the lookup again you will get a selection list with no records.  If you change the country and do the lookup it will work.

The field with the lookup in the forms is FND:Address4.

Thanks for looking at this.

Keith


[attachment deleted by admin]
Clarion 10.0.0 build 12799
NetTalk 9.31
StringTheory 2.65
InsightGraphing 2.27

Keith

  • Sr. Member
  • ****
  • Posts: 306
    • View Profile
    • Email
Re: Field Lookup problem
« Reply #3 on: August 05, 2015, 09:43:48 PM »
Hi Bruce

Have you had a chance to look at my posted example app?

Thanks

Keith
Clarion 10.0.0 build 12799
NetTalk 9.31
StringTheory 2.65
InsightGraphing 2.27

Keith

  • Sr. Member
  • ****
  • Posts: 306
    • View Profile
    • Email
Re: Field Lookup problem
« Reply #4 on: August 07, 2015, 01:55:19 AM »
Bruce,

Have been agonising over this problem and have realised that I have misunderstood the meaning of 'Field Value' in the Lookup template.  I now understand that in my example I have set the Value to the unique key of the District table which means that it is that value (a number) that is stored in the database and that any display of the field must cause a 'lookup' to be done so that the correct description can be displayed.

So, the districts are (essentially) static values and I have chosen to keep the actual district name not its number (I know!!!!). 

So, with that cleared up I at least understand what has been happening (number stored instead of description) which I didn't mention in my original post because it wasn't obvious.  But having regularised the code I still have a problem in the case on the form which is opened in Insert mode.  It now returns such as JPfskyXT into the display field.  I have seen this before but can't remember what causes it.  The template selections are identical in all three cases.

Thanks

Keith
Clarion 10.0.0 build 12799
NetTalk 9.31
StringTheory 2.65
InsightGraphing 2.27

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11251
    • View Profile
Re: Field Lookup problem
« Reply #5 on: August 07, 2015, 03:11:45 AM »
Hi Keith,

I've not got to the example yet (and you may want to post an update) but;

just to be clear.
a) The _value_ is what will be stored in the database. Good database design says this is the primary key field of the remote table, but I've seen all kinds of things in here. but assuming say an Invoice doing a lookup on Customer, then this is usually Cus:ID

b) The description is usually what the user uses to identify the record. So for customer it would be say the customers Name.

c) "Show Description instead of value" is usually set on - but then you need a _single component key_ on the description field. eg a key on cus:name. This is the best approach from a UI point of view.

cheers
Bruce

Keith

  • Sr. Member
  • ****
  • Posts: 306
    • View Profile
    • Email
Re: Field Lookup problem
« Reply #6 on: August 07, 2015, 01:42:14 PM »
Thanks Bruce for the clarification.  I do understand now how it works.

I realise that you're busy and getting to an example is a lot of work.  Don't do anything more on the example because I am working on this now and feel sure I should be able to solve it.

In this case of the Form opening in Insert mode the reason why I get 'No Districts' after first choosing a District and getting the gobbledegook posted in the field is that the filter field - Country is blanked.  I Prime it with, say, 'New Zealand' and the first Lookup filters correctly but after returning gobbldegook the value of p_web.gsv('fnd:country') is blank.  So that is something to work on.

Thanks

Keith
Clarion 10.0.0 build 12799
NetTalk 9.31
StringTheory 2.65
InsightGraphing 2.27

Keith

  • Sr. Member
  • ****
  • Posts: 306
    • View Profile
    • Email
Re: Field Lookup problem
« Reply #7 on: August 11, 2015, 12:34:14 AM »
Hi Bruce

I have created a simpler Example.  Attached are two zip files - Files.zip and Application.zip  All of the 'Files' should be copied to c:\PetMotel  The application's folder for the dictionary will need changing.

Before you generate the example - I have also attached 'Lookups.png' which shows my currenty lookup settings and it may be that just looking at this you may see the problem:

  • The Browse for the Districts selection is bDistrictsSelect
  • The 'From table is Districts
  • The 'Value Field' is Dis:RecordId which is a unique unchanging key (a Long)
  • The associated description is Dis:Name
  • Display 'description' instead of 'Value' is ticked because the popup only returns the 'Value Field'
  • Fnd:Address4 is the receiving field and the returned value is overridden in 'More Assignments'

This all seems to be per the book and I have employed a similar set of selections elsewhere with no issues so I'm stumped.

The only other thing is the filtering of the Districts records to only return those for the currently selected Country - this is performed in an embed in the bDistrictsSelect procedure.

The behaviour is that the correct districts appear in the browse but after selection the value only gets properly returned one time in ten,  If you immediately do the lookup again you will probably get 'No Districts' which is because p_web.gsv('Fnd:Country') has become blank.

Thanks a lot.

Keith

[attachment deleted by admin]
Clarion 10.0.0 build 12799
NetTalk 9.31
StringTheory 2.65
InsightGraphing 2.27

rainerwallenius

  • Jr. Member
  • **
  • Posts: 70
    • View Profile
    • Email
Re: Field Lookup problem
« Reply #8 on: August 11, 2015, 01:16:40 AM »
Hi Keith

Just curious, does it work all right if You don't use popup?

:: rainer

Keith

  • Sr. Member
  • ****
  • Posts: 306
    • View Profile
    • Email
Re: Field Lookup problem
« Reply #9 on: August 11, 2015, 02:18:43 AM »
Hi Rainer

I have tried it with pop-up off and no change to the results.

Thanks

Keith
Clarion 10.0.0 build 12799
NetTalk 9.31
StringTheory 2.65
InsightGraphing 2.27

Keith

  • Sr. Member
  • ****
  • Posts: 306
    • View Profile
    • Email
Re: Field Lookup problem
« Reply #10 on: August 12, 2015, 11:24:43 AM »
Hi Bruce

Re the latest example. I said that all of the files in Files.zip were to be in c:/PetMotel but Control.tps needs to be in the same directory as the exe.

Cheers

Keith
Clarion 10.0.0 build 12799
NetTalk 9.31
StringTheory 2.65
InsightGraphing 2.27