We can’t tell without seeing the rest of the script, but it’s probably an indentation error (or you’re missing a : at the end of an expression–something like that). There was a similar thread recently, you might try this:
Also, when posting scripts, post them as preformatted text. It helps speed up the troubleshooting process by others, see Wiki - how to post code on this forum .
assetID = self.parent.parent.getChild("AssetIDDetails").getChild("IDDisplay").props.text
assetName = self.parent.parent.getChild("AssetNameDetails").getChild("NameDisplay").props.text
lineID = self.parent.parent.getChild("LineIDDetails").getChild("IDDisplay").props.text
lineName = self.parent.parent.getChild("LineNameDetails").getChild("NameDropdown").props.value
locationID = self.parent.parent.getChild("LocationDetails").getChild("LocationDropdown").props.value
categoryID = self.parent.parent.getChild("CategoryDetails").getChild("CategoryDropdown").props.value
role_name= self.parent.parent.getChild("RoleAndWorkcenterContainer").getChild("RoleDropdown").props.value
andonDisplay = self.parent.parent.getChild("AndonDisplayDetails").getChild("AndonDisplay").props.text
roleID = 0
if role_name == 'Primary':
roleID = 1
else:
roleID = 2
modified = self.session.custom.clockNumber
try:
IDAllowed = False
if assetID == '':
# Auto-generate Asset ID
maxIDDataset = system.db.runNamedQuery('Assets/GetMaxID')
if maxIDDataset.rowCount > 0:
assetID = int(maxIDDataset[0]['Asset_ID']) + 1
IDAllowed = True
else:
# Check if custom Asset ID already exists
check = system.db.runNamedQuery('Assets/CheckExist', {'assetID': assetID})
if check.rowCount > 0:
raise Exception("ID already exists, try another ID")
else:
IDAllowed = True
system.perspective.print("Now create asset)
# --- Create asset if ID is allowed ---
if IDAllowed:
parameters = {
'assetID': assetID,
'assetName': assetName,
'lineID': lineID,
'roleID': 1 if role_name == 'Primary' else 2,
'modifiedBy': modified,
'andonDisplay': andonDisplay
}
result = system.db.runNamedQuery('Assets/CreateAsset', parameters)
if result:
# log change in Change_Log DB table
# retrieve group ID given selected group name in dropdown menu
# categoryID = self.parent.parent.parent.getChild("LineFields").getChild("SetupInformationContainer").getChild("Column2").getChild("Category").getChild("CategoryDropdown").props.value
categories = {1: 'Molding', 2: 'Paint', 3: 'Assembly', 4: 'Warehouse'}
category = categories[categoryID]
# Location from dropdown
#locationID = self.parent.parent.parent.getChild("LineFields").getChild("SetupInformationContainer").getChild("Column1").getChild("Location").getChild("LocationDropdown").props.value
location = locationID
controller = int(self.session.custom.clockNumber)
facit = str(location) + ' ' + str(category) + ' Administrator'
activity = 'Created New Line'
logchange_parameters = {'assetID': lineID, 'changeDescription':activity, 'modifiedBy':controller, 'modifierRole':facit}
system.db.runNamedQuery('Assets/Lines/LogChangeLine', logchange_parameters)
self.parent.parent.parent.parent.getChild("LocationCategoryContainer").getChild("LineDisplay").refreshBinding('props.data')
self.parent.parent.parent.parent.getChild("LocationCategoryContainer").getChild("LineDisplay").refreshBinding('props.data')
except Exception as e:
system.perspective.print("Error: {}".format(str(e)))
I am also having another error of the same kind on line 37 on the if statement as well
No closing quote.
The forum software event highlights it correctly ![]()
Wow, that was annoying…
However another error has shown up on the line just below on line 38
if IDAllowed:
parameters = {
'assetID': assetID,
'assetName': assetName,
'lineID': lineID,
'roleID': 1 if role_name == 'Primary' else 2,
'modifiedBy': modified,
'andonDisplay': andonDisplay
}
You also have a mix of tabs and spaces for indentation, which is a bad idea:
Fixed:
assetID = self.parent.parent.getChild("AssetIDDetails").getChild("IDDisplay").props.text
assetName = self.parent.parent.getChild("AssetNameDetails").getChild("NameDisplay").props.text
lineID = self.parent.parent.getChild("LineIDDetails").getChild("IDDisplay").props.text
lineName = self.parent.parent.getChild("LineNameDetails").getChild("NameDropdown").props.value
locationID = self.parent.parent.getChild("LocationDetails").getChild("LocationDropdown").props.value
categoryID = self.parent.parent.getChild("CategoryDetails").getChild("CategoryDropdown").props.value
role_name= self.parent.parent.getChild("RoleAndWorkcenterContainer").getChild("RoleDropdown").props.value
andonDisplay = self.parent.parent.getChild("AndonDisplayDetails").getChild("AndonDisplay").props.text
roleID = 0
if role_name == 'Primary':
roleID = 1
else:
roleID = 2
modified = self.session.custom.clockNumber
try:
IDAllowed = False
if assetID == '':
# Auto-generate Asset ID
maxIDDataset = system.db.runNamedQuery('Assets/GetMaxID')
if maxIDDataset.rowCount > 0:
assetID = int(maxIDDataset[0]['Asset_ID']) + 1
IDAllowed = True
else:
# Check if custom Asset ID already exists
check = system.db.runNamedQuery('Assets/CheckExist', {'assetID': assetID})
if check.rowCount > 0:
raise Exception("ID already exists, try another ID")
else:
IDAllowed = True
system.perspective.print("Now create asset")
# --- Create asset if ID is allowed ---
if IDAllowed:
parameters = {
'assetID': assetID,
'assetName': assetName,
'lineID': lineID,
'roleID': 1 if role_name == 'Primary' else 2,
'modifiedBy': modified,
'andonDisplay': andonDisplay
}
result = system.db.runNamedQuery('Assets/CreateAsset', parameters)
if result:
# log change in Change_Log DB table
# retrieve group ID given selected group name in dropdown menu
# categoryID = self.parent.parent.parent.getChild("LineFields").getChild("SetupInformationContainer").getChild("Column2").getChild("Category").getChild("CategoryDropdown").props.value
categories = {1: 'Molding', 2: 'Paint', 3: 'Assembly', 4: 'Warehouse'}
category = categories[categoryID]
# Location from dropdown
#locationID = self.parent.parent.parent.getChild("LineFields").getChild("SetupInformationContainer").getChild("Column1").getChild("Location").getChild("LocationDropdown").props.value
location = locationID
controller = int(self.session.custom.clockNumber)
facit = str(location) + ' ' + str(category) + ' Administrator'
activity = 'Created New Line'
logchange_parameters = {'assetID': lineID, 'changeDescription':activity, 'modifiedBy':controller, 'modifierRole':facit}
system.db.runNamedQuery('Assets/Lines/LogChangeLine', logchange_parameters)
self.parent.parent.parent.parent.getChild("LocationCategoryContainer").getChild("LineDisplay").refreshBinding('props.data')
self.parent.parent.parent.parent.getChild("LocationCategoryContainer").getChild("LineDisplay").refreshBinding('props.data')
except Exception as e:
system.perspective.print("Error: {}".format(str(e)))
I believe that the error is coming somewhere from there, I will go through and redo the formatting


