Page 1 of 2 12 LastLast
Results 1 to 10 of 16

Thread: Getting the mobile app / server data clear

  1. #1
    Senior Member
    Join Date
    Jan 2014
    Posts
    369

    Getting the mobile app / server data clear

    Hi Guys

    Still trying to get our heads around this.

    We believe :

    The app running on the tablet knows nothing about data.
    When a JS delegate is called to then call a server side VFP proc, we cannot assume anything about data, record pointers etc.

    The VFP server side proc should use PUSH/POP DATASESSION which makes sense if we were changing/opening tables.

    Problem :

    If we wanted to replace some data in the curent datasession (say using the results of a postcode lookup), how do we tell the server side proc which record to update?

    RECNO() doesn't seem to work as a passed parameter - presumably because there is no record number as the tablet doesn't know anything about data.

    It works well in desktop mode because the databound controls will update.

    In mobile - how do we reference the current record to then tel the VFP proc which record to change?


    We have tried the following but no good

    // Event delegate for 'dialogbutton' event
    function page1_section2_field12_dialogbutton()
    {

    var lrecno = RECNO();

    var result = Lianja.evaluate("serverside('{lrecno}')");
    };

    Any thoughts?

    Being a newbie is great sometimes - not sure that is today !!

    Cheers

    Simon

  2. #2
    Lianja MVP
    Join Date
    Feb 2012
    Location
    Berea, KY, USA
    Posts
    2,185
    Hi Simon,

    It's Lianja: you've got options.

    1) <section>.getCursor() retrieves the current record, where you can <cursor>.getData(<field>) and <cursor>.setData(<field>,<data>) You can then do a <section>.save() and (probably will need to) <section>.refresh()

    2) You can call a VFP prg with a) the PK of the record and b) the data needing to be changed. This is handy if you need to munge the data for particular purposes. In this case, you will need to get the new data, which can involve <section>.reopenTable() and a <section>.refresh(). My experience in doing this is with a parameterized VT, so I also reset the params on the section, then reopen and then refresh.

    The browser debugger is your friend: once you pull up the source, you can set a breakpoint, and then can issue these commands and see what happens.

    Hank

  3. #3
    Lianja Development Team barrymavin's Avatar
    Join Date
    Feb 2012
    Location
    UK, USA, Thailand
    Posts
    7,163
    Blog Entries
    22
    Hi Simon,

    When coding in JavaScript you need to remember that it's a case sensitive language so NAME() and name() are two different functions.

    I can see your confusion is coming from building desktop apps where the data and the code reside on the same machine. recno() is a VFP Desktop function that relies on a desktop cursor being selected and is only valid in desktop or server side code.

    As hank mentions you should use a unique primary key and pass that as a parameter to your server side function.

    Can you please explain what it is exactly that you want your app to achieve so that something straightforward does not get made unnecessarily complicated.

    Is all you want to do is have a data entry form which looks up address details based on a post code and then adds a new record on the server when all data is input? Or are you editing existing data and looking up the post code to update the record?

    We can build a quick sample app that does that for you and provide it so that you can build on from that. If you want that please contact me directly. I don't want to see you fumbling around for days trying to do something which can be achieved in hours.
    Last edited by barrymavin; 2019-09-11 at 01:58.
    Principal developer of Lianja, Recital and other products

    Follow me on:

    Twitter: http://twitter.com/lianjaInc
    Facebook: http://www.facebook.com/LianjaInc
    LinkedIn: http://www.linkedin.com/in/barrymavin

  4. #4
    Senior Member
    Join Date
    Jan 2014
    Posts
    369
    Hi Guys

    Thank you for you input - all made sense.

    Barry - we are trying to edit / update existing data

    Now spent hours searching web trying to find required info - not easy. JS Lianja Developer is very helpful but there is always just a bit missing.

    We cannot find the examples we need to understand so we are guessing as to how to send parameters to server side procs and receive a return value and are also guessing that section.refresh etc should be called from the mobile device and not from the server. There was a video about this (maybe Hank) but we cannot find it now.

    We just cannot get the server side code to fire unless it is in desktop mode. Now we have rewritten the calling delegate completely dependiant on JS, we can't get it to fire at all. It is probably just a syntax issue.

    Hank - thank you but there is no <section>.getCursor() method in the documentation so no idea how to accomplish that. We cannot get hold of the data to pass it to the server side function. As the mobile device doesnt know anything about data, how does getCursor() work?

    Barry - we know we are just 2 "aha moments" away from this being easy but cannot afford to spend days and days counting to 3.

    Will post delegate function - can you show us the error of our ways? We are sure it is blindingly obvious.

    Hoped to have had this nearly done by now .....

    Thanks in advance

    Simon
    ************************************************** ***********************

    Delegate :

    ////////////////////////////////////////////////////////////////
    // Event delegate for 'dialogbutton' event
    function page1_section2_txtPostcode_dialogbutton()
    {

    var cust = Lianja.getCursor("cust"); table cust
    var lcustid2 = cust.getData("cust_id"); character field

    Lianja.showMessage(lcustid2); this only fires if we use the first Lianja.evaluate below

    var result = Lianja.evaluate("LookUpPostcode('{lcustid2}')"); sends {lcustid2} as parameter - how do we get to the memvar?
    //var result = Lianja.evaluate("LookUpPostcode(lcustid2)"); does not run LookUpPostcode
    //var result = Lianja.evaluate("LookUpPostcode({lcustid2})"); crashes Lianja


    // if (result = 1) {
    // Lianja.showSuccessMessage("Success");
    // } else {
    // Lianja.showErrorMessage("Fail");
    // }
    //
    //Lianja.showDocument("page1:section2?action=save");
    //Lianja.showDocument("page1:section2?action=refresh ");


    };

  5. #5
    Lianja Development Team barrymavin's Avatar
    Join Date
    Feb 2012
    Location
    UK, USA, Thailand
    Posts
    7,163
    Blog Entries
    22
    I have included an example_pclookup app in the next build for you.

    Open it, run it in a web browser and study the code for the dialogbutton delegate and the getAddressDetails() server side proc.

    You can then use the same code in your App.
    Last edited by barrymavin; 2019-09-11 at 09:00.
    Principal developer of Lianja, Recital and other products

    Follow me on:

    Twitter: http://twitter.com/lianjaInc
    Facebook: http://www.facebook.com/LianjaInc
    LinkedIn: http://www.linkedin.com/in/barrymavin

  6. #6
    Senior Member
    Join Date
    Jan 2014
    Posts
    369
    Thanks Barry - that's great.

    Any idea when next build might be up?

    I'm pretty sure we were almost there - we've just ended up going round and round in circles.

    It will ceatinly help others as JS examples of parameterised function calls and their return values are so hard to find. THe VFP side should be pretty straight forward


    Wonder what the issue with the vanishing canvas sections and static images was.

    As soon as we have the demo - will let you know.

    Thanks again

    Simon

  7. #7
    Lianja Development Team barrymavin's Avatar
    Join Date
    Feb 2012
    Location
    UK, USA, Thailand
    Posts
    7,163
    Blog Entries
    22
    In a nutshell.

    Name:  Screen Shot 2019-09-11 at 3.26.35 PM.jpg
Views: 201
Size:  52.9 KB
    Principal developer of Lianja, Recital and other products

    Follow me on:

    Twitter: http://twitter.com/lianjaInc
    Facebook: http://www.facebook.com/LianjaInc
    LinkedIn: http://www.linkedin.com/in/barrymavin

  8. #8
    Lianja MVP
    Join Date
    Feb 2012
    Location
    Berea, KY, USA
    Posts
    2,185
    Oops: it's Lianja.getCursor.

    Have you looked at: https://www.lianja.com/doc/index.php..._in_JavaScript ? Lianja.getCursor() is in the first part. The part about recordset is for people who want to work with data on the backend (e.g., a .jssp page) instead of VFP.

    Hank

  9. #9
    Lianja Development Team barrymavin's Avatar
    Join Date
    Feb 2012
    Location
    UK, USA, Thailand
    Posts
    7,163
    Blog Entries
    22
    There is a new build uploaded already. It's RC54.

    I have no idea what you did with the "vanishing" canvas. I have not been able to reproduce that.
    Principal developer of Lianja, Recital and other products

    Follow me on:

    Twitter: http://twitter.com/lianjaInc
    Facebook: http://www.facebook.com/LianjaInc
    LinkedIn: http://www.linkedin.com/in/barrymavin

  10. #10
    Senior Member
    Join Date
    Jan 2014
    Posts
    369
    Hi Hank


    Yes thanks - read that.


    Cheers

    Simon

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