---
title: "Filter for a Material Lot by Custom Property 3.0"
id: "filter-for-a-material-lot-by-custom-property-3-0"
project: "Knowledge Base"
url: "https://docs.sepasoft.com/articles/knowledge-base/filter-for-a-material-lot-by-custom-property-3-0"
updated: 2026-07-23T18:08:19Z
---

# Filter for a Material Lot by Custom Property 3\.0

## Overview

The Track & Trace module provides the ability to search for specific objects by creating a filter object and then passing that to a function call to return a lists of objects that meet the filter criteria. In this article, we will setup a filter object to return a count of Material lot objects that has a specific custom property value. This would be an example of a Material lot that has a manufacturers part number as a custom property.

### Applies To and Version Info

This feature applies to Track and Trace module and is available in all versions.

## Scripting

The general syntax of the script function.

Code

```
def checkIfLotExistsByCustProp(custPropName, custPropVal):
	#This function is passed a custom property name and value and returns a count of matching lots
	#This can be used to determine if a material lot had already been entered

	# example:	custPropName = 'CoilNumber'
	#			custPropVal = '01150007715408'
	#			print checkIfLotExistsBYCustProp(custPropName, custPropVal)
           
	if custPropVal is not None and custPropVal != "" and custPropName is not None and custPropName != "":
		filter = system.mes.object.filter.createFilter()
		list = system.mes.object.filter.parseCustomPropertyValueFilter(custPropName + " = " + custPropVal)
		filter.setCustomPropertyValueFilter(list)
		filter.setEnableStateName('ENABLED')
		filter.setMESObjectTypeName('MaterialLot')
		objs = system.mes.loadMESObjects(filter)
		retVal = objs.size()
	else:
		retVal = -1

	#print "coilNumber - %s, retVal %s", str(coilNumber),str(retVal)

	return retVal
```

##