Communicate with *browser object

Started by bteixeira, May 17, 2021, 10:24:48 AM

Previous topic - Next topic

bteixeira

I'm trying to integrate my iNomads application with a third party API.  Using the *browser object, I get an iframe that navigates to the other website where the user can enter data and we get an Ajax response.  I'm able to parse this response and put the data I need into multi-lines on the iNomads page.  What I haven't been able to figure out though is how to post that data back to PxPlus process to use.  If I click into the field and press enter the on it looks like the data for that field gets pushed and the onchange logic fires off.  Is there a way (presumably in javascript) to simulate this or otherwise push the data?

Mike King

While you could emulate the inputs in iNomads its not simple as there are lots of hooks in place to attempt to Emulate the events that would occur on Windows while the user is entering the data.

To me the easiest solution would be to create a JavaScript function that could be called by your iNomads Host process to parse the iFrame data and return the information directly to the application where, if desired, you could populate the fields on the screen.

For example you could create a Javascript function and call it GetIframeData().  That function could be designed to return the data from iFrame as a JSON string.

Now in your iNomads panel create button and add standard PxPlus logic so that when the button is pressed you issue:

   JsonData$ = %iNomads'JS_Eval$("GetIframeData();")

This will Evaluate and return the value from GetIframeData on the workstation, effectively giving you access to the data you pulled from the iFrame.

Once you have the JsonData$ you can parse it and load/update and fields you want on your iNomads screen.

Now if the Third party API does not require any true user input I personally would simply issue a *plus/web/request on the server and process the response from that to fill in the iNomads fields.  That avoids the iFrame and Javascript completely. 

Most third party website have API's that don't require true user interaction other than perhaps initial connection to obtain security clearance such as oAuth2.
Mike King
President - BBSysco Consulting
eMail: mike.king@bbsysco.com

bteixeira

Using the .click() function seems to trigger the button on change logic so if I include that in the javascript listener for the API I can automatically trigger the %inomads'js_eval().  I could probably even set it up as on focus logic on a multiline and use the .focus() javascript function to trigger that.