Hi all - I’ve tried just about everything and can’t seem to get the below scrip to ignore the designer session. Any help would be greatly appreciated.
def valueChanged(tag, tagPath, previousValue, currentValue, initialChange, missedEvents):
"""
Tag change script (Gateway scope).
Opens one 'Operator Prompt' popup per active Perspective page when the tag goes True.
"""
# Only act on rising edge and skip the initial subscription callback
prev = bool(getattr(previousValue, 'value', previousValue))
curr = bool(getattr(currentValue, 'value', currentValue))
if initialChange or not curr or prev == curr:
return
popupIDBase = "my_popup"
viewPath = "myPopup"
title = "My Popup"
try:
# Get all active Perspective sessions for this gateway
sessions = system.perspective.getSessionInfo() or []
for s in sessions:
# Skip Designer sessions (we only want runtime/browser/workstation)
if s.get("sessionScope", "").lower() == "designer":
continue
sid = s.get("id")
pageIds = s.get("pageIds") or []
for pid in pageIds:
popupID = "{}_{}".format(popupIDBase, pid) # one popup per page
system.perspective.openPopup(
id = popupID,
view = viewPath,
title = title,
sessionId = sid, # required in Gateway scope
pageId = pid # required in Gateway scope
)
except Exception as e:
# Optional: log to the Gateway so you can see what went wrong
system.util.getLogger("TagChange-PromptPopup").error("Failed to open popup(s): {}".format(e))