Drop down dataProvider in EventScript editor

Hello,
In the following code, I’m trying to merge an item collection for a dropdown menu.


I have two rquestions:

  • how can I get text from the text system into a variable? In my code, only a string itself (not text where the path leads) is being set.
  • is there any way to merge dropdown data with internal client resouces? The opc variable makes it very clumsy (and I don’t really need it my application).

Thank you.
Regards
Michal Malek

Can anyone help there?

Hello!

An easy option is to use a session variable?

Or cant you just add a string array if you know how many strings there are?

Regards Nicolas

Hi Nicolas,
I can declare a session variable and assign it an appropriate string, but it cannot be bound to the data provider of a drop-down box, which requires an array of strings (ItemCollection).:


I’m looking for a workaround to achieve this.

There is a way to set text in a text widget in eventscript editor from the text system, but I’m not able to do it with a string variable.
Regards
Michal Malek

Hi Michal,
give this a try

/**
 * @eventScriptSetId screenSaverItems
 * @contentId contentStart
 */
widgets.Button1.click(async function () {
    const textKeys = [
        "Test1",
        "Test2"
    ];

    for (let i = 0; i < textKeys.length; i++) {
        const obj = {
            value: String(i),
            text: `$IAT/${textKeys[i]}`
        };

        await opcua(`::AsGlobalPV:gVisuMapp.status.ScreenSaverDD[${i}]`).setValueString(JSON.stringify(obj));
    }
});

with this as your text file.

Stephan

Hi Stephan,
thank you for your suggestion. It helped me reconsider my approach, and here is the result.


It’s running as expected.
Regards
Michal Malek