Accessing PowerShell Scripts returnCode

I'm using the PowerShell Script operation to carry out remote PowerShell activities on a server. When I am trying to use a scriptlet on a step result to access the returnCode I get an error that the scriptletRawResult is not defined.

returnCode = parseInt(scriptletRawResult['returnCode']);

Scriptlet error at line 1.
Code: returnCode = parseInt(scriptletRawResult['returnCode']);
Details: ReferenceError: "scriptletRawResult" is not defined in  at line number 1
In step PowerShell Script

How can I retrieve the returnCode from the operation via scriptlet?
Note I'm using the returnResult field as the 'From' parameter in the step result so I cannot access via scriptletInput.


Parents Reply Children
  • I also tried scriptletContext.get("returnCode") which didn't work either. Instead of returning a scriptlet error I either get a blank value or 'undefined' depending on whether I'm using Rhino or Nashorn.
    Note that when using scriptletContext.get(), it's not just the returnCode which produces this behaviour but all other result fields behave in the same way.

    I'm not doing anything advanced, simply create a new flow and add the PowerShell Script operation, wiring up the transitions to success and failure responses.
    Remove all inputs from the PowerShell script step, apart from script and populate it with Get-Host
    Add a step result, and add a scriptlet filter consisting of scriptletResult = scriptletRawResult["returnCode"];
    Run the flow and observe the error message.

    You can see the attached screenshots with this info., I also should point out tha I'm using HP OO Studio 10.70 Build 16.

  • I believe we have seen this same issue.  The work around for us is to set the return code in the script and return that information.  From there the returnResult is filtered to get the information. 

    Example in the PowerShell to return the return code and a return message:

      $ReturnCode   = 2
      $ReturnString = "Errror Message"
      $results | Add-Member -MemberType NoteProperty -Name "returnCode" -Value $ReturnCode
      $results | Add-Member -MemberType NoteProperty -Name "returnResults" -Value $ReturnString 

      return $results


  • I have managed to work around it for now by adding a new step result (sr_returnCode) that gets its value from the returnCode result field. I am then able to access the return code in a scriptlet on another step result by using scriptletContext.get("sr_returnCode");

    In your example I would need to know what the return code and error message should be in order to output the result but I want PowerShell to deal with that and pass the info to OO. You can see it does do this when looking at the raw result in the step result inspector., for some reason though, they just don't seem to be accessible by a scriptlet.