from psdi.mbo import SqlFormat owner = mbo.getOwner() # Ensure that it's a tool as this object is used by item as well if owner and owner.getName()=="TOOLINV": toolQualSet=owner.getMboSet("$EMXTOOLQUAL","TOOLQUAL","itemnum=:itemnum and itemsetid=:itemsetid") toolQualMbo=toolQualSet.moveFirst() while toolQualMbo: # Multiple records could exist, so we need to validate that the user has qualifications for each whereClause="qualificationid=:qualificationid and orgid=:orgid and status='ACTIVE' and (enddate is null or enddate>:&SYSDATE) and exists(SELECT 1 FROM labor WHERE labor.laborcode=laborqual.laborcode and labor.orgid=:orgid and labor.personid=:1)" sqf=SqlFormat(whereClause) sqf.setObject(1,"LABOR","PERSONID",mbo.getString("ISSUETO")) qualLaborMbo=toolQualMbo.getMboSet("$EMXLABORQUAL","LABORQUAL",sqf.format()).moveFirst() if not qualLaborMbo: service.error("emx","missingToolQualification",[mbo.getString("ITEMNUM"),toolQualMbo.getString("QUALIFICATIONID")]) toolQualMbo=toolQualSet.moveNext()