AttributeError("'NoneType' object has no attribute 'getChild'",)

Hello everyone,

I’m currently experiencing an unexplained issue with an Edit Change Script on the Parameter PassedOnOrderID.

Whenever a value is being passed on to the PassedOnOrderID Parameter the following Script is executed:

# Retrieve the passed ID or order number
passedOnID = self.params.PassedOnOrderID 
system.perspective.print('passedOnID is: ' + str(passedOnID))

# Get a reference to the table component
table = self.getChild("root").getChild("fc_Offline_Programmieraufträge").getChild("Table_Orders")  # Adjust path to table
system.perspective.print('Table is: ' + str(table))

# Retrieve the data of the table
tableData = table.props.data  # Data must be fully loaded
system.perspective.print('tableData is: ' + str(tableData))

# Find the row index that corresponds to the passed ID or order number
rowIndex = next((index for index, row in enumerate(tableData) if str(row["ID"]) == str(passedOnID)), None)
system.perspective.print('rowIndex is: ' + str(rowIndex))

# If a valid row index is found, open the subview
if rowIndex is not None:
    table.expandSubviews([rowIndex])  # Open the subview of the corresponding row
else:
    system.perspective.print("No row index found matching the passed OrderID.")

This script has been working successfully across multiple projects. However, for some reason, an issue arises when trying to assign the table component to the variable table . I consistently encounter the following error:

AttributeError("'NoneType' object has no attribute 'getChild'",)

Interestingly, this works without any problems:

table = self.getChild("root").getChild("fc_Offline_Programmieraufträge")

But as soon as I try to directly reference the table, like this:

table = self.getChild("root").getChild("fc_Offline_Programmieraufträge").getChild("Table_Orders")

I get the error.

What I’ve checked so far:

Table Path : The path seems correct since the parent node is found without issues. I’ve also verified that the table exists in the Designer and is correctly named.

Does anyone have any idea what could be causing this or how I can debug the issue further?

Thanks in advance for your help!

Have you tried renaming the component to not contain an umlaut? That shouldn't matter, but it's the only "unusual" thing I can see there...

This isn't actually doing anything - table could be assigned null/None here and you wouldn't know until you try to dereference it.

Try this:
table = self.getChild("root").getChild(u"fc_Offline_Programmieraufträge").getChild("Table_Orders")

In Python 2, you need to declare (via the u prefix for unicode) that you're writing out a constant string that may contain non-ASCII characters, such as the accented a.

2 Likes

What I actually wanted to say with this code snippet:

table = self.getChild("root").getChild("fc_Offline_Programmieraufträge")

is that the error AttributeError("'NoneType' object has no attribute 'getChild'",) no longer occurs. However, as soon as I append .getChild("Table_Orders"), the error is thrown. Unfortunately, I didn't make that clear, apologies for the confusion.

As a matter of fact, replacing the 'Umlaut' (ä, ü, ö) worked wonders!
Thanks, guys—this community, as always, proves to be incredibly helpful!

Right, you are still somewhat confused as to the real error. When you get an error that a NoneType is missing an attribute, it means a prior operation yielded a None that you weren't expecting. In this case, the

.getChild("fc_Offline_Programmieraufträge")

That yielded a None instead of the expected component object, because your accented character was mangled by jython's standard string constant interpretation. Adding the u"" syntax to the string constant fixes the mangling. Or renaming so you don't need a unicode string to avoid the problem.

2 Likes