def updateWO(allornothing):
mx = MXServer.getMXServer()
wo_set = mx.getMboSet("WORKORDER", mx.getSystemUserInfo())
wo_set.setWhere("...") # Your specific where clause here
wo_set.reset()
wo = wo_set.moveFirst()
has_error = False
while wo:
try:
# Attempt to set the description value
wo.setValue("DESCRIPTION", "ABC")
except MXException as e:
has_error = True
if allornothing:
# If all-or-nothing, stop further updates and break out
break
else:
# Log or handle the error for this specific work order
print(f"Failed to update work order {wo.getString('WONUM')}: {str(e)}")
# Move to the next work order in the set
wo = wo_set.moveNext()
if allornothing:
if has_error:
wo_set.rollback() # Rollback if any errors occurred
print("Rolled back all changes due to an error.")
else:
wo_set.save() # Save only if no errors occurred
else:
# Save all successful changes regardless of errors
wo_set.save()
print("Saved all successfully updated work orders.")
# Cleanup the MboSet
wo_set.close()