01-19-2024 12:56 PM
Hi,
I am wondering if I can create a global variable in a workflow that can be shared/updated between the different device instances during a script activity. I created a variable, and I made it's scope "WORKFLOW":
but it seems that if I manipulate this variable within a "script activity" in different device instances, it's not really global in that sense if I have multi devices running; I find that for the "script activity" every device has it's own until the activity is done then it it just takes the last device.
Not sure if I am making myself clear, but I want to be able to manipulate a variable (add entries to it) from the same script activity for different devices.
Thanks,
Solved! Go to Solution.
01-23-2024 07:19 AM
If 10 devices get executed each activity has per device the own thread to run in parallels. If all writing to the same global variable the last wan will win.
The alternative I explained is more complicated to set and relay on the activity ID, but it makes sure that each thread (device) gets its data shared.
Also, you can consider using the device annotation to store data per device. Or using site variables depends on what you like to achieve.
write device annotation
mutation {
network {
configureDevice(input: {
deviceConfig: {
ipAddress: "192.168.0.11"
deviceAnnotationConfig: {
userData1: "my stuff"
}
}
}) {
message
status
}
}
}
read device annotation
{
network {
device(ip: "192.168.0.11") {
deviceData {
userData1
}
}
}
}
01-30-2024 11:45 PM
this is a different question than you initially ask for. please open a new thread next time.
you can update messages in three contexts
emc_results.put("workflowMessage", "Some custom workflow message" )
emc_results.put("activityMessage", "Some custom activity message" )
emc_results.put("deviceMessage", "Some custom device message" )
As well you can change the end result of a workflow
emc_results.setStatus( emc_results.Status.ERROR )
emc_results.setStatus( emc_results.Status.CANCELED )
emc_results.setStatus( emc_results.Status.SUCCESS )
emc_results.setStatus( emc_results.Status.COMPLETED )
emc_results.setStatus( emc_results.Status.PENDING )
emc_results.setStatus( emc_results.Status.STARTED )
emc_results.setStatus( emc_results.Status.NOT_SUBMITTED )