Results 1 to 10 of 10

Thread: Keylookup issue

  1. #1
    Senior Member
    Join Date
    Apr 2012
    Location
    United Kingdom
    Posts
    516

    Keylookup issue

    Just starting to get back into Lianja after a long time away from it due to other work commitments.

    Using javascript as I want this to run on the web

    On a page section I have a field which is in a table danimal and the field contains a foreign key to table dtaxon.

    The get data mapping setting of keylookup("dtaxon","PRIMARY",{},clatin)

    I would expect to see the latin name of the species on the page, but only see the foreign key

    In the console for vfp if I use the actual key value with

    ? keylookup("dtaxon","PRIMARY","5d5ea001-a05a-4e36-b17f-1e016ae5827f",clatin)

    If displays the latin name as expected

    in the javascript console I get a message

    Wed Oct 21 16:40:12 2020
    **** Lianja JavaScript error ****
    Traceback (most recent call last):
    SyntaxError: Parse error

    Any ideas what I'm doing wrong?

  2. #2
    Lianja Team yvonne.milne's Avatar
    Join Date
    Feb 2012
    Location
    Berkshire, UK
    Posts
    1,460
    Hi David,

    You are missing quotes around the {} and the return expression.

    https://www.lianja.com/doc/index.php/Data_Mapping

    https://www.lianja.com/doc/index.php/KEYLOOKUP()

    Regards,

    Yvonne

  3. #3
    Senior Member
    Join Date
    Apr 2012
    Location
    United Kingdom
    Posts
    516
    Hi Yvonne,

    Looking at the documentation https://www.lianja.com/doc/index.php/Data_Mapping

    Name:  keylookup.png
Views: 24
Size:  13.6 KB

    In the page I have just tried

    keylookup("dtaxon","PRIMARY","{}","clatin")

    and

    keylookup("dtaxon","PRIMARY","{}",clatin)

    but no luck

    Are the quotes a javascript thing as it works in the vfp console as originally put

    Regards

    David

  4. #4
    Lianja MVP
    Join Date
    Feb 2012
    Location
    Berea, KY, USA
    Posts
    2,010
    Hi David,

    Your second one should have worked, without the quotes around the 4th parameter. The reason they are needed for the 3rd parameter is that your FK value is a Char.

    The control/column you are on of course is the FK field, right?

    Hank

    Hank

  5. #5
    Senior Member
    Join Date
    Apr 2012
    Location
    United Kingdom
    Posts
    516
    Hi Hank,

    Thanks for the tip on the char entry, the documentation just shows it as {}, I'll try again with this tomorrow and see if I can get it working.

    Yes it's an FK field, cfk_dtaxon in table danimal

    The odd thing is that when I enter it in the vfp console it works

    In the page even if I try setting as

    keylookup("dtaxon","PRIMARY","5d5ea001-a05a-4e36-b17f-1e016ae5827f",clatin)

    it does not work, which is exactly what I have the vfp console. Maybe it's that I'm setting javascript as the language for the app and it's pages etc

  6. #6
    Senior Member
    Join Date
    Apr 2012
    Location
    United Kingdom
    Posts
    516
    Hi Hank,

    When would the third parameter, the current value in the text box, not be a char as it would always be an FK to another table would it not?

    I understood that {} meant the current value of the text box for example

    David

  7. #7
    Lianja MVP
    Join Date
    Feb 2012
    Location
    Berea, KY, USA
    Posts
    2,010
    Hi David,

    Some people use numerics for PKs -- what is being places there by the {} is the value of the control. Barry owns the system, so he can make it do whatever he wants.

    Hank

  8. #8
    Senior Member
    Join Date
    Apr 2012
    Location
    United Kingdom
    Posts
    516
    I see from the docs that for web mobile I need to use the full databases name, I'll try that.

    I hope that works as well for vfp code as I want to set this once at the table level and have it work on all apps, desktop or web / mobile rather than coding in pages for it

  9. #9
    Senior Member
    Join Date
    Apr 2012
    Location
    United Kingdom
    Posts
    516
    OK getting somewhere now

    keylookup("aim!dtaxon","PRIMARY","{}",clatin,"Not found")

    The above works in the javascript and also in vfp so I can just set it at the table level to get it into my pages.

  10. #10
    Lianja MVP
    Join Date
    Feb 2012
    Location
    Berea, KY, USA
    Posts
    2,010
    Yes, in fact I had forgotten the DB! part for Javascript. The calls to the LCS know which app, of course, but a given app can work with more than one database, and "state" of database is not known, as it would on desktop using Lianjascript.

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Journey into the Cloud
Join us