NetTalk Central

Author Topic: Filling NetWebForm with data from an API client (NT 12.19)  (Read 3096 times)

jking

  • Sr. Member
  • ****
  • Posts: 419
    • View Profile
    • Email
Filling NetWebForm with data from an API client (NT 12.19)
« on: June 26, 2021, 05:18:16 PM »
Hi Bruce,

     I'm working on a NT app where I have a NetWebForm opened.  Fields are blank as this is an insert.  On the form I have a button that calls an API client window.  The prototype/parameter of this window is set to (NetWebServerWorker p_web).  When I click the button to call the API client, it does successfully get data, as seen in the attached screen shot.  The API Client stores the retrieved data in a queue.  I would like to "move" this data to the currently open form, before saving the form.
     Currently, I have code in the API client that opens the form's target TPS file, and does an Insert or Update as needed.  However, the fields on the form are not updated upon returning to the form.
     How can I update an open form with the data I get from the API Client?

Thanks,

Jeff King

jking

  • Sr. Member
  • ****
  • Posts: 419
    • View Profile
    • Email
Re: Filling NetWebForm with data from an API client (NT 12.19)
« Reply #1 on: June 27, 2021, 03:46:31 PM »
Hello all,

     I think I have a solution.  In the PageReceived embed of my API Client, I process the returned JSON data.  I set the form field names like this:

    p_web.SSV('PatMKD:LATERALITY', jsonItem.GetValueByName('SiteOfDCIS'))
    p_web.SSV('PatMKD:BIOPSY_TYPE', jsonItem.GetValueByName('BiopsyType'))
    p_web.SSV('PatMKD:PALPABILITY', jsonItem.GetValueByName('Palpable'))
    p_web.SSV('PatMKD:TUMOR_SIZE', jsonItem.GetValueByName('TumorSize'))
    p_web.SSV('PatMKD:NUCLEAR_GRADE', jsonItem.GetValueByName('Grade'))

As I mentioned earlier, on the NetWebForm I have a button that calls the API Client procedure.  On the Client-Side tab of this button, I reset the fields shown above.  Works great!  Fields on the form are populated with the data from the API Client, I click Save and I'm done.  The key is to set the prototype/parameter of the API Client window (a standard Clarion window) to "NetWebServerWorker p_web".  This gives it access to the session data.

Thanks,

Jeff King

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Filling NetWebForm with data from an API client (NT 12.19)
« Reply #2 on: June 27, 2021, 11:58:55 PM »
perfect.