[RPG/JS]Get the value of GVAR

Please do not use to report errors- use your regional help desk.
Please mark posts as being for RPG or RDMLX (LANSA) developer.
To subscribe by email, display this forum, scroll to the end and select ‘Subscribe Forum’.
Post Reply
MegumiSawada
Posts: 259
Joined: Tue Feb 19, 2013 5:18 pm

[RPG/JS]Get the value of GVAR

Post by MegumiSawada » Tue Aug 08, 2017 2:28 pm

Hi,

I have an application to set the value of Textbox element to GVAR in javascript.
I'd like to show the value of that GVAR as a message of message box.

I thought I can retrieve the value of GVAR with "this.q_getProperties({"SharedStates.USERID":[]}); " statement, but i am not able to get the value.

TextBox WFUSID --> GVAR: USERID --> Messagebox

Code: Select all

function() { 
			this.q_setProperties("form.fields.WFUSID.Value.&.GVAR","USERID");
                         this.q_apply();
                        this.q_getProperties({"SharedStates.USERID":[]}); 
               }, 
function(value1) { 
        myMessage = this.value1;
        this.q_setProperties({
            runOperation:
            {
                type: "ShowMessage",
                title: "Info",
                message: myMessage
}});
How can I get the value of GVAR in the same javascript ?
I can pass the GVAR to the other formview, but I'm not sure how to get the value of GVAR within the same javascript.

Best Regards,
Megumi Sawada

mwilliams
Posts: 17
Joined: Fri May 19, 2017 1:34 am

Re: [RPG/JS]Get the value of GVAR

Post by mwilliams » Wed Aug 09, 2017 4:06 am

Try just doing

myMessage = value1;

tsupartono
Posts: 289
Joined: Wed Apr 18, 2012 10:21 am

Re: [RPG/JS]Get the value of GVAR

Post by tsupartono » Wed Aug 09, 2017 9:23 am

Megumi,
You can also get a shared state value using the q_getState function - give that a try.
See the following section in the LongRange documentation site:
http://www.longrangemobile.com/docs/lrp ... evalue.htm
Use container type 0.

Also a quick reminder that any q_XXXX invocation must be the last statement in the current function.
E.g, the following is not allowed and will result in an undefined behaviour:

Code: Select all

lrexec(
function() {
   q_setProperty...
   q_getProperty...
});
Instead you should break those 2 q_XXXXX invocation into 2 separate functions:

Code: Select all

lrexec(
function() 
{
   q_setProperty... 
},
function() 
{
   q_getProperty...
});

MegumiSawada
Posts: 259
Joined: Tue Feb 19, 2013 5:18 pm

Re: [RPG/JS]Get the value of GVAR

Post by MegumiSawada » Wed Aug 09, 2017 11:39 am

Hi mwilliams and Tony,

Thank you for your advice!
I was able to get the value of GVAR with the following code.
Your advice helped me a lot.

Code: Select all

function() { 
			this.q_setProperties("form.fields.WFUSID.Value.&.GVAR","USERID");
               }, 
function() { 
this.q_getProperty("SharedStates.USERID"); 
               }, 
function(value4) { 
        myMessage = value4;
Thank you!
Megumi

Post Reply