Printing a window from a tag change script

Hello, so I am trying to print a window based on a tag change event script. I have put together the code on how to do it, but haven’t had any luck getting it to fully execute. My script is this:

system.nav.openWindow(‘Main Windows/ReceivingReport’)
system.nav.centerWindow(‘Main Windows/ReceivingReport’)
def clickButton(): import system
Button = window.rootContainer.getComponent(‘Container/Print Button’)
system.util.invokeLater(clickButton, 2000)

So when the script runs the windows change and get centered but the doClick() is not executing. The button is inside of another container on the window, but I have tried placing the button in the root container and still it will not work.

It doesn’t look like you’re telling it to use doClick() anywhere.

Try:

window.rootContainer.getComponent(‘Container/Print Button’).doClick()

I tried using the .doClick at the end but it tells me my object has no attribute ‘doClick’

Is the code above the only code you’ve got running?

if so, then you’re not telling it what ‘window’ is.

Also, where is this code being run from? An on screen button? internalFrame event handler? This matters as the pathing changes

The script is being ran from a client event change script. This is the only client event script I have running. I have some gateway scripts running but they work fine.

Ok, so to tell it what window it is you need:

window = system.gui.getWindow('Main Windows/ReceivingReport')

This will find any open instance of a window with that path. If it doesn’t find an open window with that path you’ll get an error.

So try:

system.nav.openWindow(‘Main Windows/ReceivingReport’)
system.nav.centerWindow(‘Main Windows/ReceivingReport’)

def clickButton(): 
      import system
      window = system.gui.getWindow('Main Windows/ReceivingReport')
      window.rootContainer.getComponent(‘Container/Print Button’).doClick()
system.util.invokeLater(clickButton, 2000)

I’m not sure the ‘Container/Print Button’ bit is right though… I can’t remember off the top off my head.

So everything went well except for the .doClick() it’s still hungup there. Perhaps I don’t have the right path going to the object?