AttributeError: 'NoneType' object has no attribute

I am receiving the error below when using the attached code. I checked the help and saw that selectedStringValue is a valid property. I can comment out any of the line and get the same error just a reference to the next line. Is there something I am missing?

Error Message:
Traceback (most recent call last):

File “event:actionPerformed”, line 1, in
File “module:project.Insert_Shift_Info”, line 3, in Insert_Shift_Information
AttributeError: ‘NoneType’ object has no attribute ‘selectedStringValue’

Ignition v7.7.4


[code]def Insert_Shift_Information(event):
window = system.gui.getParentWindow(event).rootContainer
strShift = window.getComponent(“Shift_Dropdown”).selectedStringValue
Date = “’” + window.getComponent(“Shift_Date_Select_Calendar”).formattedDate[:10] + “’”
strLine_Name = “’” + window.getComponent(“Line_Name_Dropdown”).selectedStringValue + “’”
intParts_Produced = window.getComponent(“Parts_Made_Numeric_Text_Field”).intValue
intScheduled_Parts = window.getComponent(“Parts_Scheduled_Numeric_Text_Field”).intValue

system.db.runUpdateQuery("INSERT INTO Shift_Information (Line, Date, Shift, Parts_Produced, Scheduled_Parts) VALUES (%s, %s, %s, %s, %s)" % (strLine_Name, Date, strShift, intParts_Produced, intScheduled_Parts))[/code]

Hi dturner,

There error that you are getting means that the component path you are using, “Shift_Dropdown” does not exist, so None is being returned by the call to getComponent. Are you sure that the “Shift_Dropdown” component is in the root container? Are you sure you spelled the name of the component exactly as it appears in the Project Browser in the designer? Are you sure you are getting the right window?


I copied and pasted the component name into the script and received the same error. This is the parent window. The script is being launched from a button press. I’ve attached the tree in Designer.

You’re missing the “rootContainer” property between “window” and “getComponent()”.

Do I need to put that again even though I have it in the variable window = system.gui.getParentWindow(event).rootContainer?

Use the property reference browser to get the correct path to the component along with the property name.

[quote=“dturner”]Do I need to put that again even though I have it in the variable window = system.gui.getParentWindow(event).rootContainer?[/quote]Whoops, I missed that. No.