I have two scripts that are run from a Visual Overview:
- One that reads 5 different values from a memory file and populates 5 different Card Variables (this is executed automatically when the card is opened)
- One that sets a new value to one of the memory file positions and updates the corresponding Card Variable (this is executed by clicking a shape)
Both scripts work fine except that after setting a new value in the memory file in the second script its corresponding Card Variable is never updated (but if I close the card and reopen it the new, correct value is shown). I've made sure that the Option field is set to CardVariable on the shape that executes the second script as well as on the page level for the first script. I even tried running the first script again as a sub-script in the end of the second script with the InheritScriptOutput SubScriptOption without success.
This is the second script:
string liveId = (string) engine.GetScriptParam("liveId").Value;
// create a UI that will display a line of text and a textbox
UIBuilder uib = new UIBuilder();
uib.AppendLine($"Configure source for {liveId}:");var elementSDNOVideo = engine.GetDummy("elementSDNOVideo");
var tableKeys = elementSDNOVideo.GetTableDisplayKeys(800);
Array.Sort(tableKeys);
var inputs = tableKeys.Select(input => $"{input}|{input}").ToArray();uib.AppendDropDown("opt", inputs);
uib.AppendButton("btn", "SET");// show the UI and wait for a response
UIResults uir = engine.ShowUI(uib);if(uir.WasButtonPressed("btn")) {
string selectedInput = uir.GetString("opt");
var inputIndex = (string) elementSDNOVideo.GetParameter(801, selectedInput);ScriptMemory memoryFile = engine.GetMemory("LivePanel");
memoryFile.Set(Int32.Parse(liveId), inputIndex);engine.AddOrUpdateScriptOutput(UIVariables.VisualOverview.CreateKey($"LiveSource{liveId}"), inputIndex);
}
Hi Robin,
It's not possible from an Interactive Automation Scripts to update a variable on a Visual Overview. There is task DCP180165 which will make this available.
As a workaround you can use following flow:
- Launch not interactive script when user click on button
- Launch interactive subscript which will return the variable value to its parent script
- Parent script will try to set the value to a variable on the visual
Parent script
Subscript
First you need to link this script to your user
Afterwards you can send the variable back to the parent script
The InheritScriptOutput property is by default true, so not mentioning it shouldn’t make any difference.
I don’t understand the last changes that you did. I can understand that you don’t use the AddResource method since this is a copy-paste from a script of my own 🙂 But I guess that you are still using method Add(OrUpdate)ScriptOutput in your subscript and in your parent script? If that’s the case then all should be fine.
I only use AddScriptOutput in the subscript and it works. Using it in the parent as well will cause it to throw an error saying the Key already exists.
Thank you, this worked! I did replace the first “foreach” with “subscriptOptions.InheritScriptOutput = true;”
and I skipped the AddResource method (just used engine.AddScriptOutput in the subscript), still worked. Are there any unforeseen consequences of me skipping those parts?