Unable to access output parameter

I'm attempting to build a process-flow that calls a script, and then uses the last string output by the script to determine if the script failed or not.  I've checked the out-of-the-box Job-Chains and have found about 30 examples of Job-Steps that appear to do just this. The pattern always seems to be the same…

1. in the first job-step invoke the script and set [ParameterOutName] to [Value = "my_script_results"]

2. in the next step use [ &OUT(my_script_results)& ] to access the output of the script

When I do this in my own Process, the [ &OUT(my_script_results)& ] isn't getting expanded.

In Job-Queue Info, you see that the output of the script is getting correctly assigned to [ParameterOutName] in the first step. The next step has a [my_script_results] parm added, and it is also set to the same script-output. Regardless, the expression "&OUT(my_script_results)&" isn't getting replaced with the script-output.

What can be going wrong?

I see another thread discussing this issue, and see that Barry explained that Job parameters are calculated when the Job-Chain is launched, and not while they are running. As this may be true, why do the OOTB processes use a script that fetches a string and then in the next tile, the string is injected into a SQL statement. I would therefore expect my code to just work.

This code always returns "not expanded"… 

Dim my_parm As String = ""
 
my_parm = "&OUT(my_script_results)&"
 
If my_parm = "&OUT(" & "my_script_results" & ")&" Then
   Value = "not expanded"
Else
   Value = "expanded to " + my_parm
End If
 

  • You need to distinct between two important points in time. The time the process instance (jobchain) is generated and saved into the database and the time the individual process step is processed by the Job service.
    Your vb.net sippet is run prior to initially saving the process instance into the database. Your snippet gets rid of "&OUT(my_script_results)&" before the process step is saved into the database. Output parameters are handled by the Jobservice and replaced immediately before running a process step. In your case "&OUT(my_script_results)&" never makes it into the database. The Jobservice never encounters "&OUT(my_script_results)&" and therefor never replaces "&OUT(my_script_results)&" with the out value calculated by your my_script_results script.
    The SQL Statements with output parameters in OOTB processes work because their "&OUT(OutpuParameterName)&" parts make in into the process instance (and the database) and therefor the Jobservice can replace them with the actually output parameter value immediately before running the process step.
    When you simulate your process in the Designer you will see that "&OUT(my_script_results)&" is already gone. When you simulate an OOTB process with a SQL statement containing an output parameter you will see that the "&OUT(OutpuParameterName)&" still is in the parameter value.
  • Andreas, in the Simulate I see what you mean.  The "&OUT(xxx)&" is gone.  I agree this is the problem, but I still am unable to uderstand what the difference is between what I'm doing and what the OOTB processes are doing.   Some of the OOTB jobs have simply...    Value = "&OUT(xxx)&"   as parameter.  If I do the same, the parm is empty at run-time.

    I can't understand what I'm doing wrong.  If I switch back and forth between my process and the OOTB processes, I can't see any difference.

  • Oh.  Sometimes I'm so stupid.  Found my problem.  It is exactly as you explained.   The code in all your parameters executes when the entire jobchain is loaded.  Not as each step is executed.  Whatever string is written to "Value" after the code executes needs to contain the "&OUT(xxx)&".   You can't treat it as a variable, because when the code executes, it's just a string.

    At any rate, the expression    Value = "&OUT(xxx)&"  should always work.  As Craig explained, this can be passed to another script.   The reason it wasn't working for me was because the script that was returning "xxx" was throwing an exception, and then the output was empty.

    As I said.  Sometimes I'm so stupid.   Everything is working now.

    Thanks.