Can you poll data from a screen into a global script?

I have looked at the following posting

viewtopic.php?f=23&t=4745

And it seemed close to what i want to do. However I keep getting an attributes error.

What I am trying to do is within a Global script poll the a data set from a page if the page is open. SO far I have the if page is open part working, what I can seem to get is the final part where it will poll the data from that page. Here is what I have so far:

[code]try:
window = fpmi.gui.getWindow(‘Test Window’)
from fpmi.gui import getWindow
window1 = getWindow(“Test Window”)

data = fpmi.db.toPyDataSet(window1.Container.getComponent('Job Tasks').getComponent('notes').data)

data1 = fpmi.db.toPyDataSet(window.rootContainer.Container.getComponent(‘Job Tasks’).getComponent(‘Table’).data)

print data

except ValueError:
fpmi.gui.warningBox(“The Turnover window isn’t open”)[/code]

and here is the error message that I get when I try to run this script

Traceback (innermost last):
File “<KeyBinding:FPMI KeystrokeAction:pressed F1>”, line 6, in ?
AttributeError: instance of ‘com.inductiveautomation.factorypmi.application.FPMIWindow’ has no attribute ‘Container’

at org.python.core.Py.AttributeError(Py.java)
at org.python.core.PyObject.__getattr__(PyObject.java)
at org.python.pycode._pyx149.f$0(<KeyBinding:FPMI KeystrokeAction:pressed F1>:6)
at org.python.pycode._pyx149.call_function(<KeyBinding:FPMI KeystrokeAction:pressed F1>)
at org.python.core.PyTableCode.call(PyTableCode.java)

Thank you for taking the time to look at this and have a Merry Christmas and a Happy New Year.

I think your code should look more like this:[code]try:
window1 = getWindow(“Test Window”)

data = fpmi.dataset.toPyDataSet(window1.rootContainer.getComponent(‘Job Tasks’).getComponent(‘notes’).data)
print data
except ValueError:
fpmi.gui.warningBox(“The Turnover window isn’t open”)[/code]

Al thank you for responding. I did after reading realize that i forgot to mention that I did try doing it with a script that looks like your. And I also forgot to mention that on the screen in question I have the root container, then I have container, then the component.

So if you look at the hieracy it is the screen, then root container, then container, then the components.

I have tried

data = fpmi.dataset.toPyDataSet(window1.rootContainer.Container.getComponent(‘Job Tasks’).getComponent(‘notes’).data)

And I have tried the way in which I posted and the way in which you posted. And none of them work so far. I know it has to be something stupidly simple just cant lay my finger on it.

[quote=“AlThePal”]I think your code should look more like this:[code]try:
window1 = getWindow(“Test Window”)

data = fpmi.dataset.toPyDataSet(window1.rootContainer.getComponent(‘Job Tasks’).getComponent(‘notes’).data)
print data
except ValueError:
fpmi.gui.warningBox(“The Turnover window isn’t open”)[/code][/quote]

mt,

The container is a component just like any other, so you would need to use the getContainer method to get a reference to it. Try this:

from fpmi.gui import getWindow window = getWindow("Window Name") container = window.rootContainer.getComponent("Container") tasks = container.getComponent("Job Tasks") notes = tasks.getComponent("notes") data = notes.data This worked on the attached window. Once you get this working, you can eleminate some of the intermediate assignments if you want.
notes.fwin (7.18 KB)