Page 1 of 1

[RPG/JS]Get the value of GVAR

Posted: Tue Aug 08, 2017 2:28 pm
by MegumiSawada
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

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

Posted: Wed Aug 09, 2017 4:06 am
by mwilliams
Try just doing

myMessage = value1;

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

Posted: Wed Aug 09, 2017 9:23 am
by tsupartono
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...
});

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

Posted: Wed Aug 09, 2017 11:39 am
by MegumiSawada
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