Getting Component Values From Script

hello. I am currently trying to get the value of a checkbox that exists in a window from a script. However, I am having trouble with an error that notes “window (xyz) is not currently open.”. Has anyone been able to perform this? How so?

This is the code statement causing the error:

system.gui.getWindow("DataLoad").rootContainer.getComponent("ChkBoxDepartment").selected

Your syntax is correct. The error seems obvious. If the DataLoad window isn’t open, there’s no checkbox.

The window is definitely open as the scripting function is being called from a button on that window.

While your syntax seems correct, if the button is on the same window as the as the checkbox, you can simplify your call by doing:

system.gui.getParentWindow(event).getRootContainer().getComponent('ChkBoxDepartment').selected

Edit: Changed the selector to one that is more likely going to work in more cases.

Right. And I have that working. But I am looking to move the code you mentioned to a script, which means I need to use the Open Window I originally posted.

Are you sure that the name of the window is exactly DataLoad? Is it inside of any folders, maybe?

1 Like

Maybe there is something I am missing? I am relatively new to Ignition. Do I need to include Project/Main Windows/DataLoad??

You are missing Main Windows/DataLoad. Right click on your window and select Copy Path.

3 Likes

Thank you!