system.mes.batch.recipe.syncPhasesAndSaveRecipe(mesObjectList)

Sepasoft MES Module Suite

system.mes.batch.recipe.syncPhasesAndSaveRecipe(mesObjectList:MESObjectList)

Synchronize phases to their latest version and save master recipe and associated logic objects that were created or modified. Use this function instead of the system.mes.saveMESObject() script function. A validation of the recipe will be done prior to saving.

Note

Version Specific: 3.81.10 RC3 and later

Parameters

mesObjectList: MESObjectList A MESObjectList object containing the BatchMasterRecipe and associated BatchMasterLogic objects to save.

Returns

None

Single Recipe Script Example

This script synchronizes the phases of one specific recipe and saves it.

Here’s how it works:

  • Sets the target recipe to Test Recipe and its recipe class to Test Recipe Class.
  • Loads that recipe class using None as the parent context, then converts it into a link with .asLink().
  • Finds Test Recipe within that class.
  • Loads the recipe into saveList.
  • Calls syncPhasesAndSaveRecipe(saveList) to synchronize its phases and save the recipe, storing the result in syncResult.

Python
recipeName = 'Test Recipe'
recipeClassName = 'Test Recipe Class'
recipeClassLink = system.mes.batch.recipe.loadRecipeClass(recipeClassName, None).asLink()
recipeLink = system.mes.batch.recipe.getRecipeLink(recipeName, recipeClassLink)
saveList = system.mes.batch.recipe.loadRecipe(recipeLink)
syncResult = system.mes.batch.recipe.syncPhasesAndSaveRecipe(saveList)

Multiple Recipe Script Example

This script walks through the recipe hierarchy and synchronizes and saves every master recipe it finds.

Here’s how it works:

  • Starts at the root

Python
parentLink = None
getRecipeAndSyncPhases(parentLink)

  • Passing None is intended to start at the top of the recipe hierarchy.

  • Gets the children under the current parent
    It requests the first page of recipe links, with up to 1,000 results and an empty search filter.

  • Checks each linked object
    It loads the MES object and reads its type and name.

  • Synchronizes master recipes
    If the object type is BatchMasterRecipe, it:

    • Prints RECIPE: followed by the recipe name.
    • Gets the recipe link using its name and parent.
    • Loads the recipe into saveList.
    • Calls syncPhasesAndSaveRecipe(saveList) to synchronize its phases and save it.
  • Recurses into other objects
    For every object that isn’t a master recipe, it prints RECIPECLASS: and calls the same function with that link as the parent, treating it as a recipe class or folder.

  • Python
    def getRecipeAndSyncPhases(parentLink):
    	pageNumber = 0
    	pageSize = 1000
    	searchPattern = ''
    	linkList = system.mes.batch.recipe.getRecipeLinkList(parentLink, pageNumber, pageSize, searchPattern)
    	for link in linkList:
    		obj = link.getMESObject()
    		objTypeName = obj.MESObjectTypeName
    		objName = obj.name
    		if objTypeName == 'BatchMasterRecipe':
    			print 'RECIPE:', objName
    			recipeLink = system.mes.batch.recipe.getRecipeLink(objName, parentLink)
    			saveList = system.mes.batch.recipe.loadRecipe(recipeLink)
    			syncResult = system.mes.batch.recipe.syncPhasesAndSaveRecipe(saveList)
    		else:
    			print 'RECIPECLASS:', link
    			getRecipeAndSyncPhases(link)
    
    parentLink = None
    getRecipeAndSyncPhases(parentLink)


Sepasoft MES Module Suite