Page 1 of 1

Accessing variable values in different record formats

Posted: Wed Jul 15, 2020 11:48 am
by Theju112
I have two record formats in a display file. When a button is clicked on the first record format, the control is passed to the RPG program by the below javascript code set in OnClick property:

Code: Select all

changeElementValue("CCS1ACTION","MAP");
pui.click('btnSubmit');
The CCS1ACTION field value ("MAP") shows up in the RPG program as required.

But what I am trying to do is to use the value of the CCS1ACTION field value in the OnLoad Javascript of the second record format. But as I found out, this value is not visible in the Onload javascript of the second record format.

I have put the below statement in the OnLoad script of the second format and I see the value Undefined.

Code: Select all

alert(CCS1ACTION.getElementValue);
What I want to access is the value set to CCS1ACTION from the first screen though the ChangeElementValue method.

Kindly provide your suggestions on how this can be achieved.

Re: Accessing variable values in different record formats

Posted: Wed Jul 15, 2020 12:15 pm
by Scott Klement
Your code is wrong, it should be:

Code: Select all

alert(getElementValue("CCS1ACTION"));
That assumes that CCS1ACTION is the "id" property of a widget that is on the current display.

You mention that there is more than one record format, but you did not mention how you are displaying them or what the id of the widget is. You can use the debugging tools in your browser to inspect the elements on the page to determine this.

Re: Accessing variable values in different record formats

Posted: Wed Jul 15, 2020 1:05 pm
by Theju112
Hi Scott,

I just figured this out by myself when the profound ui javascript prompter (auto-complete) showed the getElement method.

The tough thing about debugging in my case is that I am running an Android app on the bluestacks android emulator and I am not aware of any "debugging" tools in the emulator. Hence I am having to guess whats wrong if somethings not working as expected.

Re: Accessing variable values in different record formats

Posted: Wed Jul 15, 2020 1:45 pm
by Scott Klement
I'm not familiar with BlueStacks, but it usually makes sense to test a mobile app in Chrome first, then deploy it to mobile.

With an actual Android device, it's also possible to connect a USB cable to the Android device and connect it to a Chrome browser so that you can use Chrome's debugging tools to debug an application running on the device.

Re: Accessing variable values in different record formats

Posted: Mon Aug 03, 2020 12:43 pm
by Theju112
Thank you Scott. As I have learned, most emulators (including bluestacks) have an option to present themselves as a USB connected android device to Chrome. Hence these appear as remote devices in the chrome dev tools. So we dont really need a physical android device to test.