Skip to main content
Version: 7.9

system.sfc.setVariable

This function is used in Python Scripting.

Description

Sets a variable inside a currently running chart.

Client Permission Restrictions

Permission Type: SFC Management

Client access to this scripting function is blocked to users that do not meet the role/zone requirements for the above permission type. This function is unaffected when run in the Gateway scope.

Syntax

system.sfc.setVariable(instanceId, [stepId], variableName, variableValue)

Parameters

TypeParameterDescription
StringinstanceIdThe instance identifier of the chart.
StringstepIdThe id for a step inside of a chart. If omitted the function will target a chart scoped variable. [Optional]
StringvariableNameThe name of the variable to set.
ObjectvariableValueThe value for the variable to be set to.

Returns

Nothing

Scope

All

note

Omitting the stepId parameter will cause the function to target a chart scoped variable. If the variable is persistent to the whole chart, or used in multiple different steps, then this parameter should be omitted.

If a stepId parameter is used, then the function will target a step scoped variable. The step associated with the stepId must be the currently active step.

Code Examples

Code Snippet
# The following passes the chart instance ID and step ID to a client message Handler. The message handler can then wait
# for user input, and then write back to the step variables.

# The example assumes there is a chart scoped variable called confirmEndchart, and a step scoped variable called "messageSent".

# Get the instanceId of the current chart
chartID = chart.get("instanceId")

# Get the id of the step
stepID = step.get("id")

# Create a payload to pass to the client.
# Include the instanceId and stepId so the script from the message handler knows which
# chart and step to write to
payload = {"chartID" : chartID, "stepID" : stepID}

# Send the message
system.util.sendMessage(project = "SFC", messageHandler = "SFCMessage", payload = payload

############

# The following script would be placed on a client message handler. This receives the payload,
# and sets a variable on either the chart or step depending on user selection

# Read items out of the payload
id = payload['chartID']
stepId = payload['stepID']

# Ask the user to end the chart
if system.gui.confirm("Would you like to end the process"):
#If yes, end the chart. confirmEndChart is chart scoped, so only 3 parameters are passed
system.sfc.setVariable(id,"confirmEndChart",True)
else:
#If no, reset the step.messageSent variable so that the user will be prompted again
#messageSent is step scoped, so 4 parameters are passed
system.sfc.setVariable(id,stepId,"messageSent",False)