Skip to end of metadata
Go to start of metadata

Overview

this is an extension of Adding Custom Properties to a Work Order and Custom Properties Column(s) in the MES Work Order Table 

this Work Order Table has 2 Custom Properties : Facility and Work Center

right click on a Work Order and you'll get a small pop up to create either or list them (list in the console in this code)

select to enter a value for Facility and ..

Setup

Set the User Menu Item Property of the Work Order Table 

Right Click on the Work Order Table and goto Scripting

You will have to work with
userMenuItemClicked => this will know what to do when you right click on a Work Order and choose one of the options defined above
onColumnsCreate => will define the Custom Properties displayed in the Work Order Table
onRowAdd => will display in the column created in onColumnsCreate the values you entered in userMenuItemClicked

# userMenuItemClicked code
if event.getMenuItemName() == 'Add CP Facility':

    woObj = event.getWorkOrder()
    #Add Facility to be used for this Work Order as a custom property
    parentPath = 'Facility'
    dataType = 'String'
    description = 'Facility Desc'
    units = ''
    productionVisible = True
    required = False
     
    #Add Facility custom property directly to the MES object
    woObj.addCustomProperty(parentPath, dataType, 'Facility', '', productionVisible, required)
     
    name = 'Facility X'
    value = system.gui.inputBox('Enter a Value for Facility X:')    
    woObj.addCustomProperty(parentPath, name, dataType, description, units, productionVisible, required, value)
    print "added : name [%s] : value [%s]"% (name, value)  
  
    system.mes.saveMESObject(woObj)
    system.mes.invalidateCache()
    #print woObj.getCustomPropertiesFull()
    
elif event.getMenuItemName() == 'Add CP Work Center':

	woObj = event.getWorkOrder()
	#Add Work Center to be used for this Work Order as a custom property
	parentPath = 'Work Center'
	dataType = 'String'
	description = 'Work Center Desc'
	units = ''
	productionVisible = True
	required = False
	
	#Add Facility custom property directly to the MES object
	woObj.addCustomProperty(parentPath, dataType, 'Work Center', '', productionVisible, required)
	
	name = 'Work Center'
	value = system.gui.inputBox('Enter a Value for Work Center:')    
	woObj.addCustomProperty(parentPath, name, dataType, description, units, productionVisible, required, value)
	print "added : name [%s] : value [%s]"% (name, value)  
	
	system.mes.saveMESObject(woObj)
	system.mes.invalidateCache()
	#print woObj.getCustomPropertiesFull()
	
elif event.getMenuItemName() == 'Get Custom Properties ?':

    woObj = event.getWorkOrder()
  	
    print woObj.getCustomPropertiesFull()
# onColumnsCreate code

	import java.lang
	return {'Facility': java.lang.String, 'Work Center': java.lang.String}


# onRowAdd code

	f = mesWorkOrder.getPropertyValue('Facility.Facility X')
	#f = mesWorkOrder.getCustomPropertyValues('WorkOrder','Facility')
	print f
	
	w = mesWorkOrder.getPropertyValue('Work Center.Work Center')
	print w

	return {'Facility': f, 'Work Center': w }

 

Keywords

Work Order Table, Custom Property, userMenuItemClicked, onColumnsCreate, onRowAdd

OEE

Configuration, Scheduling, Run-control-and-Monitoring: Adjusting-OEE-Run-values or Adjusting-Production-count, Analysis-and-reports, Production-data.



  • No labels