Skip to end of metadata
Go to start of metadata

Maybe because you are working on a Legacy DB, such as a copy of a Dev or QA system, you have a whole lot of Schedule Entries, 
from testing that are stuck in the past, for example created in Manual Pending and never started.

please do NOT use a SQL Query to disable these.

Instead use the following script that will use MES Object Functions and update the Schedule View and Selector in a proper way

Step-by-step guide


  1. use the following code 

    f = system.mes.object.filter.createFilter()
    f.setMESObjectTypeName("OperationsRequest")
    objs = system.mes.loadMESObjects(f)
    
    #dateBegin = system.date.addDays(system.date.now(), 1)
    # or
    # remember for some wacky reason month starts at zero :) so November is 10 !
    dateBegin = system.date.getDate(2018, 10, 1) 
    dateEnd = system.date.getDate(2018, 11, 31) 
    print "From ", dBegin, " To ", dateEnd
    
    faultList = system.mes.object.list.createList()
    
    for obj in objs:
    	if "Pending" in obj.getSegmentScheduleState() and obj.getBeginDateTime().before(dateEnd) and obj.getBeginDateTime().after(dateBegin): 
    	
    		print "Sched [%s] [%s] BeginDateTime [%s]" % (obj.getName(), obj.getSegmentScheduleState(), obj.getBeginDateTime())
    		
    # run this once to check the list is what you expect .. then ..
    # comment the lines below to change the Status to "Failed"
    #		obj.setSegmentScheduleState("Failed")
    #		faultList.add(obj)
    #system.mes.saveMESObjects(faultList)


Operations Schedule