Just an update, I've managed to maske some progress
not sure where i got the
.before idea from but it wasn't working.
I've change my script to the following, but it still has issues when trying to compare dates
from java.util import Calendar
from java.util import Date
from psdi.server import MXServer
from psdi.mbo import MboConstants
parentwo=mbo.getMboSet("PARENT").getMbo(0)
childwoexinsptype = mbo.getString("WO11")
locationvisinsp = mbo.getDate('LOCATION.VISINSPDATE')
locationdetinsp = mbo.getDate('LOCATION.DETINSPDATE')
childwoactfinish = mbo.getDate('ACTFINISH')
#SET CHILD WO ACTSTART AND ACTFINISH THE SAME AS PARENT WO
mbo.setValue("ACTFINISH",parentwo.getDate("ACTFINISH"),MboConstants.NOACCESSCHECK | MboConstants.NOVALIDATION_AND_NOACTION)
mbo.setValue("ACTSTART",parentwo.getDate("ACTSTART"),MboConstants.NOACCESSCHECK | MboConstants.NOVALIDATION_AND_NOACTION)
#CHECK IF THE CHILD EX INSPECTION TYPE IS NOT POPULATED AND CASCADE THE VALUE FROM THE PARENT WO
if(childwoexinsptype ==""):
parentwoexinsptype = parentwo.getString("WO11")
mbo.setValue("WO11",parentwoexinsptype,MboConstants.NOACCESSCHECK | MboConstants.NOVALIDATION_AND_NOACTION)
#CASCADE THE ACTFINISH DATE TO THE LOCATION DEPENDANT ON EX INSPECTION TYPE
if (locationvisinsp is None and mbo.getString('WO11') == 'VISUAL INSP OK'):
mbo.setValue("LOCATION.VISINSPDATE", parentwo.getDate("ACTFINISH"))
elif (locationvisinsp < parentwo.getDate("ACTFINISH") and mbo.getString('WO11') == 'VISUAL INSP OK'):
mbo.setValue("LOCATION.VISINSPDATE", parentwo.getDate("ACTFINISH"))
elif (locationdetinsp is None and mbo.getString('WO11') == 'DETAILED INSP OK'):
mbo.setValue("LOCATION.DETINSPDATE", parentwo.getDate("ACTFINISH"))
elif (locationdetinsp < parentwo.getDate("ACTFINISH") and mbo.getString('WO11') == 'DETAILED INSP OK'):
mbo.setValue("LOCATION.DETINSPDATE", parentwo.getDate("ACTFINISH"))
else:
pass
------------------------------
Richard White
------------------------------
Original Message:
Sent: Tue August 23, 2022 06:31 AM
From: Richard White
Subject: Cascading data
Hello all, i'm after a bit of help.
I'm trying to get a script working to cascade information from a work order to it's child workorders and child locations.
I've got it working to a fashion but i get the following error when the value of WO11 is blank or not one that i have specified.
| |
from java.util import Calendar
from java.util import Date
from psdi.server import MXServer
from psdi.mbo import MboConstants
from psdi.mbo import SqlFormat
v_childexinsptype = mbo.getString("WO11")
par=mbo.getMboSet("PARENT").getMbo(0)
v_wostatus = par.getString("STATUS")
v_wopm = par.getString("PMNUM")
v_wositeid = par.getString("SITEID")
visinsp = mbo.getDate('LOCATION.VISINSPDATE')
detinsp = mbo.getDate('LOCATION.DETINSPDATE')
actfinish = mbo.getDate('ACTFINISH')
if(v_childexinsptype=="" and v_wopm is not None and (v_wostatus == 'COMP' or v_wostatus == 'CLOSE' or v_wostatus == 'CAN')) :
v_exinsptype = par.getString("WO11")
mbo.setValue("WO11",v_exinsptype,MboConstants.NOACCESSCHECK | MboConstants.NOVALIDATION_AND_NOACTION)
if (visinsp is None and mbo.getString('WO11') == 'VISUAL INSP OK'):
mbo.setValue("LOCATION.VISINSPDATE", actfinish)
elif (visinsp.before(actfinish) and mbo.getString('WO11') == 'VISUAL INSP OK'):
mbo.setValue("LOCATION.VISINSPDATE", actfinish)
elif (detinsp is None and mbo.getString('WO11') == 'DETAILED INSP OK'):
mbo.setValue("LOCATION.DETINSPDATE", actfinish)
elif (detinsp.before(actfinish) and mbo.getString('WO11') == 'DETAILED INSP OK'):
mbo.setValue("LOCATION.DETINSPDATE", actfinish)
------------------------------
Richard White
------------------------------
#AssetandFacilitiesManagement
#MaximoIntegrationandScripting
#Maximo