Skip to content
Miriam McMahon edited this page Apr 27, 2023 · 6 revisions

Description

The value to return from a function or operation.
An operation should always return a boolean value for Safeguard to consume.

A function can return a simple type (e.g. boolean or string) or a complex object. Within the script, the function call and definition must each treat the return variable as the exact same type, otherwise the script will report an error.

If using a simple type, then the variable syntax can be used to access the variable value, e.g. %VariableName% or %VariableName::$defaultifnullorempty%.
If using a complex type, then you must access a variable using expression syntax, e.g. %{ VariableName }% When using expression syntax, the expression within the markers: '%{}%' must be a valid C# expression For more information about accessing variables, see Variable Reference

Parameters

Parameter Name Description Type Resolved Type Required
Value The value to be returned Value Any Yes

Examples

Example: return a simple type:

{
    "Return": { "Value": true }
}

Example: return a complex type from function 'TestFunction':

{
    "Function":
    {
        "Name":"TestFunction", 
        "Do":
        [
            {
                "Return": 
                { 
                    "Value": 
                    {
                        "ResultBool" : true,
                         "ResultString": "this is a return string"
                    }
                }
            }
        ]
    }
}

Example: access the complex type returned from TestFunction :

{
    "Function" : {
        "Name":"TestFunction",
        "ResultVariable": "TheResult"
    }
},
{ 
    "Log": 
    {
            "Text" :
            {
                "Function TestFunction returned the bool: %{ TheResult.ResultBool }% and string : %{ TheResult.ResultString }%"
            }
    }
}