mtlozl Regular Contributor.
Regular Contributor.
319 views

accessing powershell variable output from scriptlet

Jump to solution

Hello All,

I am using the powershell script pack ( i copied it from base content pack ) for testing purpose.

I need to access the assigned powershell variable value in scriptlet, but i don't know how can i acsess it ?

input script include only that ps command ->    "$retDate = get-date"

and i want to access $retDate value from scriptlet... ( i must use $retDate variable )

for example;

$retDate variable taked value is "10/04/2018"

if i can access it , i will apply to below control, in scriptlet;

var a = $retDate

if(a == "10/04/2018"){

     scriptletResponse = "success";

}else{

     scriptletResponse = "failure";

0 Likes
1 Solution

Accepted Solutions
Micro Focus Expert
Micro Focus Expert

Re: accessing powershell variable output from scriptlet

Jump to solution

Hi,

In order to access variables in scriptlets you can't use the ${varName} approach as that is a construct created for OO. To get them you have to use the style as shown below:

var a = inputName 

Use this if the variable is an input on the operation you are using.

var a = scriptletContext.get("variableName");

Use this if the variable is a local flow variable.

var a = scriptletContext.getLocal("variableName");

Use this if the variable is a result on the current step.

Hope this helps,

Vlad

1 Reply
Micro Focus Expert
Micro Focus Expert

Re: accessing powershell variable output from scriptlet

Jump to solution

Hi,

In order to access variables in scriptlets you can't use the ${varName} approach as that is a construct created for OO. To get them you have to use the style as shown below:

var a = inputName 

Use this if the variable is an input on the operation you are using.

var a = scriptletContext.get("variableName");

Use this if the variable is a local flow variable.

var a = scriptletContext.getLocal("variableName");

Use this if the variable is a result on the current step.

Hope this helps,

Vlad

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.