Hi, I am having a problem setting a scene Datalinq key from a text object in OnSetText. I have looked at many other posts with people trying to do the same, some say this works, some say it doesn't. I believe I am scripting it correctly, and inside the script, the key does appear to be set. However, when the text field changes again, the key reverts to its original value (in my case blank),
Here's my setup:
1. I have a simple scene with a single DataLinq key named SportCode. It is not published, but I've tried that and it makes no difference.

2. I have a text field with a combo box list of sports leagues (NFL, NBA, MLB, NHL).
3. In OnSetText of that field, I have the following script:
dim keys as xpDatalinqKeys
dim key as xpDatalinqKey
if (Scene.GetDatalinqKeys(keys)) then
if (keys.GetKeyByName("SportCode", key)) then
Engine.DebugMessage("(Before) sport code is " + key.AsString, 0)
Engine.DebugMessage("Attempting to set to " + text + "..." , 0)
key.AsString = text
Scene.RefreshDatalinqs
Engine.DebugMessage("(After) sport code is " + key.asString, 0)
end if
end if
Here is the output in the console when I change the value of the combo box (ie. select a new league):
16-01-2020 12:44:39 Notify: (Before) sport code is
16-01-2020 12:44:39 Notify: Attempting to set to NHL...
16-01-2020 12:44:39 Notify: (After) sport code is NHL
16-01-2020 12:44:46 Notify: (Before) sport code is
16-01-2020 12:44:46 Notify: Attempting to set to MLB...
16-01-2020 12:44:46 Notify: (After) sport code is MLB
16-01-2020 12:44:48 Notify: (Before) sport code is
16-01-2020 12:44:48 Notify: Attempting to set to NBA...
16-01-2020 12:44:48 Notify: (After) sport code is NBA
16-01-2020 12:44:48 Notify: (Before) sport code is
16-01-2020 12:44:48 Notify: Attempting to set to NFL...
16-01-2020 12:44:48 Notify: (After) sport code is NFL
So as you can see, the key is found in the scene's Datalinq keys, the key is valid, and the key appears to be getting set properly inside the script. But the next time the script runs, it's back to being blank (or whatever the key was manually initialized with). It's not sticking, therefore I can't use the key elsewhere.
I've tried Scene.RefreshDatalinqs() as a method call, with and without the parentheses (people on this forum have reported it doesn't work using the parentheses), but it doesn't matter.
I've also tried doing the same thing in OnPrepare and OnPreviewRender, with the same (broken) results.
For now, this is all running locally, there is no MOS gateway or sequencer involved.
Is this some v9 bug or am I doing something wrong? It almost looks like the Datalinq keys returned from the function are a copy (ie. "ByVal"), even though the SDK docs say "ByRef", implying that operations (like assigning a value to a key) should be performed on the original objects. Any ideas on this?
