Scense Administrator Guide

  1. Home
  2. Docs
  3. Scense Administrator Guid...
  4. Advanced Task Structures
  5. Function Variables

Function Variables

‘Function Variables’ are a special kind of Query Variables that allow for custom dynamic variables based on a Scense Scripting Action.

Function variables can be used in all situations where variables can be used.

Before using Function Variables some preparation is in order:

    1. Create a new Taskset named e.g. “Functions”
    2. Remove all Session Events from this new Taskset
    3. Set the ‘status’ for this Taskset to ‘Functions’
    4. Within this Taskset create a new Session Event of type ‘Functions’

(Newly installed Scense systems already have the above preparations in place.)

Now Scripting Actions can be added to the ‘Function Scripts’ event.

These scripting Actions can make use of two properties:

    • FunctionParameter
      (Input) Holds the parameter for the function script.
    • ReturnValue
      (Output) Holds the return value as generated by the script.
      This return value will be the value that replaces the variable specification at runtime.

Function Variables use syntax similar to the Query Variable.

Common Query Variable’s name syntax:

Consider this example:

The above Function Variable will call the ‘GetUserDescription’ function script from the Functions Taskset and the return value from this function script will replace the variable specification.

This could be the ‘GetUserDescription’ function script:

If the above function variable specification is used at runtime it will be replaced by either the user’s account name or his ‘full name’ depending on the full name being specified by the administrator.

The function variables can also be used with input parameters:

The above Function Variable will call the ‘GetUserDescription’ function script (as shown below) from the Functions Taskset and the return value from this function script will replace the variable specification.

This could be the ‘GetUserDescription’ function script:

If the above function variable specification is used at runtime it will be replaced by either the user’s account name or his ‘full name’ depending on the full name being specified by the administrator, and this name will be suffixed by the user type.

It is possible to enter variables as a function parameter.

In order to keep the syntax intact these variables must be surrounded with @ instead of %.

Like this:

Here the variable %UserName% is passed to a function as @UserName@ so it will not disturb the syntax.

A construction like this:

is possible but harder to comprehend.

Best Practice

The ‘Query Variables’ and the ‘Function Variables’ can be complex and using these variables repeatedly is prone to typo’s and syntax errors.

To avoid this, the administrator can make use of a Site Parameter construction.

Let’s consider this query variable:

%WINMGMTS://.\root\cimv2|Select BuildNumber from Win32_OperatingSystem%

And let’s assume this variable is used quite often in conditions.

The administrator might find himself typing this variable over and over again, with the risk of making a mistake.

The administrator is unable to browse for such a variable because the browser is unaware of any query- or function variables.

This can be easily solved by creating a new Site Parameter, like this:

    1. Open the ‘Default site’ property page from the ‘Administrative Tools\Sites’ folder.
    2. Switch to the ‘Parameters’ page to see the list of Site Parameters
    3. Click the ‘Add’ button to add a new Site Parameter
    4. Type a name for the new parameter, e.g. BuildNumber
    5. Type or paste the value for the parameter,
      e.g. %WINMGMTS://.\root\cimv2|Select BuildNumber from Win32_OperatingSystem%
    6. Type a description for the new parameter, e.g. BuildNumber
    7. Click OK

This new %BuildNumber% variable will show up when browsing for variables and can be used anywhere.

This is an excellent way of extending the variable collection of Scense with custom variables.