Absent Member.. mathinasulthan Absent Member..
Absent Member..
681 views

How to get value of variable in scriptlet in hpoo

Jump to solution

 How to get the value of reportMemory variable in scriptlet in flow  and use this variable in next flow  in hp oo

 

scriptlet:
   scriptletContext.putGlobal("reportMemory", reportMemory);
   scriptletContext.putGlobal("warningMemory", warningMemory);

Labels (1)
0 Likes
1 Solution

Accepted Solutions
Highlighted
Absent Member.. apresence Absent Member..
Absent Member..

Re: How to get value of variable in scriptlet in hpoo

Jump to solution

First, there are local and then there are global context variables.  Unless you intentionally want your variable visible to parent flows, a local variable is what you need.  Assuming that is the case, read on...

 

To store the script variable 'some_var' in the local context variable 'myvar':

some_var = 'foo';

scriptletContext.put('myvar', some_var);

 

To retrieve the value in a later script and store it in 'some_other_var':

some_other_var = scriptletContext.get('myvar');

 

Note that scriptletContext.get() will return null if the variable is not set.  You can check for this as follows:

if (some_other_var == null) {

  some_other_var = 'some_default_value';

}

 

Alternatively:

if (scriptletContext.containsKey('myvar')) {

  some_other_var = scriptletContext.get('myvar');

}

else {

  some_other_var = 'some_default_value';

}

0 Likes
2 Replies
Absent Member.. JasonCantrell Absent Member..
Absent Member..

Re: How to get value of variable in scriptlet in hpoo

Jump to solution

Hello Mathinasulthan,

 

I am an OO support representative and will be researching your question.  From what I understand you are simply trying to get a value of a variable in a scriptlet.  I will see if I can find the answer an post it for you today.

 

Kind Regards,

Jason

HP Support
If you find that this or any post resolves your issue, please be sure to mark it as an accepted solution.
0 Likes
Highlighted
Absent Member.. apresence Absent Member..
Absent Member..

Re: How to get value of variable in scriptlet in hpoo

Jump to solution

First, there are local and then there are global context variables.  Unless you intentionally want your variable visible to parent flows, a local variable is what you need.  Assuming that is the case, read on...

 

To store the script variable 'some_var' in the local context variable 'myvar':

some_var = 'foo';

scriptletContext.put('myvar', some_var);

 

To retrieve the value in a later script and store it in 'some_other_var':

some_other_var = scriptletContext.get('myvar');

 

Note that scriptletContext.get() will return null if the variable is not set.  You can check for this as follows:

if (some_other_var == null) {

  some_other_var = 'some_default_value';

}

 

Alternatively:

if (scriptletContext.containsKey('myvar')) {

  some_other_var = scriptletContext.get('myvar');

}

else {

  some_other_var = 'some_default_value';

}

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.