# The following Action step script 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) |