[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 1:18 am

[RPG/JS]Get the value of GVAR

Post by MegumiSawada » Mon Aug 07, 2017 11: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: Thu May 18, 2017 10:34 am

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

Post by mwilliams » Tue Aug 08, 2017 1:06 pm

Try just doing

myMessage = value1;

tsupartono
Posts: 289
Joined: Tue Apr 17, 2012 7:21 pm

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

Post by tsupartono » Tue Aug 08, 2017 6:23 pm

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 1:18 am

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

Post by MegumiSawada » Tue Aug 08, 2017 8:39 pm

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