Gateway script access to calling container's properties

I am working on a script will be shared among many clients as well as being used multiple times within the project. The script takes the values of various dropdowns, textboxes, checkboxes, etc. and generates an xml file to send to an industrial printer. Is there a way to reference the calling container’s properties in the gateway script?
For example, I currently use the syntax below to access the component’s property from another component’s mouseReleased event script.
name = event.source.parent.getComponent(‘Dropdown’).selectedStringValue
I then pass the variable ‘name’ to the global script:
xml = shared.PS.printControlToXML(name, etc…)

Is I possible to do something like this in a gateway (or project) script?
name = reference_from_calling_container.getComponent(‘Dropdown’).selectedStringValue

If this is possible, can somebody help with an example of the proper syntax?

TIA

Don

You can’t even call gateway scripts from clients, so, no. And even within the client or designer, no. Not automatically. If you need to pass a container to a script in a module, make a function argument for it. From an event, you’d pass event.source.parent there.
Depending on whether you really need gateway scope, you may be able to achieve what you want with system.util.sendMessage or .sendRequest, but gui objects cannot be placed into the message payload – they are confined to their origin scope.

It also sounds like you’re potentially over complicating things. If you just want to write your code once, and use it in all your clients, then use the shared scripts folder - as long as you’re calling those functions from the client scope, you’ll be able to use whatever GUI related code you need. If you do truly need to then hand it off to the gateway scope to actually perform a print, then you can have all of that code in a gateway message handler.

1 Like

Update - - -
My issue has been resolved.:triumph:
In order to access the GUI properties from the shared script, it is necessary to pass the calling event to the shared script. The calling event (in my case a button press) is:

xml = shared.PS.PC_ToXML(event)

The shared script declaration is:

def PC_ToXML(event):

Accessing values from the GUI components within the script:

name = event.source.parent.getComponent(‘Dropdown’).selectedStringValue

Thanks for your replies