This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Modifying Workflow Parameters in a script

Hello,

I'm currently running ARS 6.9 and am trying to understand some basic workflow functionality.

 

For a basic example I have a test workflow like so:

There's a parameter for it aptly named 'TestParam'. This parameter is set as a string that's value is defined by a script:

Next, the script is run, all it does is return a string:

 function onInit ($Request)
{
    $Test = "Hello World"    
    return $Test
}

Lastly, a report to verify the parameter setting from the script:

The end result of this is:

 

 

 

Clearly the parameter is not being set. One thing I noticed is in the script properties, the 'function to declare parameters' option. I've set it to the onInit function but when I open the 'Specify Parameters' box there are no parameters listed:

It's from this I'm presuming I need to set more in the script itself. I have read through the SDK on the $Context object but it states 'internal object "Context" that implements the AddParameter method used to add a new parameter to your policy script'. This suggests creating a brand new parameter in the workflow not modifying an existing one which is where I'm getting a little confused. Anyone able to steer me true on this? I think I'm close I'm just missing a key concept here.

Thanks!

 

  • Are you more interested in receiving values back FROM your script or sending values TO your script?

    In the latter case, if you setup the parameter in the workflow definition, you can reference it in your script thus:

    # Get an input file name from the workflow

    # Assumes the name 'inputfile' was assigned to the parameter name in the workflow definition

    $InputFileName = $workflow.parameter("InputFile")
  • I'm more interested in receiving values from my script, sending values to I have figured out in another one.

    Thanks.
  • To expand on this, although I'm using 6.9 and this documentation is for 7.0, per this article:
    support.quest.com/.../70

    Step 9 states:
    'If you want to use a script to assign a value to the parameter at workflow run time, click Use script to determine parameter values below the Acceptable values box. Then, click the button next to the Script name box to select the script module containing the desired script. The script module must be created beforehand. After you have selected a script module, in the Function to assign a value to this parameter list click the name of the script function. You can choose from the script functions that exist in the script module. The function must be designed to return a value that matches the syntax of the parameter.'

    How this reads suggests that if I return a string from a script, the parameter should pick up a string - can anyone elaborate on this?