Skip to content

SetItem

Miriam McMahon edited this page Apr 27, 2023 · 9 revisions

Description

Create or update a variable and its value.
The variable can be a simple (e.g. string) or complex object type: the type is determined by the value assigned to the variable. By default, a variable is created with local scope (ie within the current 'Do' block). For more information about defining and accessing variables, see Variables

Parameters

Parameter Name Description Type Resolved Type Required
Name The string used to identify the variable. If it already exists, the existing variable will be replaced. String String Yes
Value The value of assign to the variable Value Any No
IsSecret Set to true to suppress logging within this component if the variable might contain sensitive data. Default= false. Boolean Boolean No

Examples:

Example: Create a simple variable within the local scope

{
    "SetItem": {
        "Name": "index",
        "Value": 0
    }
},

Example: Create a array variable within the local scope

{
  "SetItem": {
    "Name": "rhymeString",
    "Value": [ "Mary", "had", 37, "little", "lambs" ]
  }
},

Example: Create a boolean variable with global scope, that can be referenced anywhere in the platform script

{
    "SetItem": {
        "Name": "Global:EatChocolate",
        "Value": true
    }
},

Example: Create a complex object variable

{
    "SetItem": {
        "Name": "complexObject",
        "Value": {
           "MyName" : "object1",
           "MyValue1": 100,
           "AnotherValue" : {
              "Name": "one",
              "TheValue" : "two"
           }
        }
    }
}