module.run = function (self) { //Place your Code here // CONFIG const nameOfItem = 'SInt', valueOfItem = 1, popupWidgetName = 'my-popup'; // CONFIG END // Variables let popup = null, subscriptionToken = null; // Create UI Action instance const core = shmi.visuals.core, parameters = [ { "name": "popup-menu", "params": [ "."+popupWidgetName, "open" ] } ]; const action = new core.UiAction(parameters); // Get item manager handle const im = shmi.visuals.session.ItemManager; const myItemHandler = im.getItemHandler(); myItemHandler.setValue = function (value) { console.log("The value of the item has been set to " + value); if (value == valueOfItem) { action.execute(); } }; // Wait until the popup has been initialized shmi.onReady( { controls: { popup: "."+popupWidgetName } }, function (resolved) { // Subscribe to the item and bind the item handler subscriptionToken = im.subscribeItem(nameOfItem, myItemHandler); } ); /* called when this local-script is disabled */ self.onDisable = function () { self.run = false; /* from original .onDisable function of LocalScript control */ // Unlisten when no longer req'd (e.g. in handlers) - don't leave this out! if (subscriptionToken) { subscriptionToken.unlisten(); subscriptionToken = null; } }; };