Lot Attributes
A lot is only an ID, a name, an item and a unit, and its lot events give it a quantity, location and state. Real material carries more than that: the supplier's own lot number, a steel heat number, an expiry date, a moisture reading, a certificate of analysis. Lot attributes hold these facts.
A lot attribute is a name and a value attached to one lot. A lot can have as many attributes as you need.
| Information | Where it belongs | Example |
|---|---|---|
| How much, where, and in what condition | Lot events, from lot operations | 900 lbs at Receiving, OK |
| True for every lot of an item | Item attributes | The standard shelf life of STD-COAT |
| True for this lot only | Lot attributes | Supplier lot ALC-24-0917 |
Keep these in mind when you plan lot attributes:
- Names are free text. There's no list to configure: the first time a name is used, it exists.
Supplier Lotandsupplier lot #are two different attributes, so agree the names before go-live. - Values are text. Write dates as
2027-04-30and put units in the name, such asHardness (HRC), so values sort and compare the same way everywhere. - Attributes stay on their lot. A lot operation doesn't copy them to its output lots, but you can see the attributes of every lot in a genealogy together.
- Editing overwrites. An attribute keeps who created it and when, not its earlier values.
- Deleting a lot deletes its attributes.
Lot Attributes in Lot Manager
Lot attributes are on the Lot Attributes tab below the lot table in Ops → Lots → Lot Manager. Adding, editing and deleting them needs the Configure Lots permission.
You'll record the supplier's information on the raw materials you received in Execute the Trace, and an inspection result on the coated parts.
- In Lot Manager, select the aluminum lot (
RAL000000000x) and open the Lot Attributes tab. - Click Add Lot Attribute (+). In Lot Attribute, type
Supplier Lot, enter the valueALC-24-0917, and click Save. - Add a second attribute to
RAL000000000x:Heat Number,H58213. - Select the
STD-COATlot (RBI000000000x) and addExpiry Date,2027-04-30. The Lot Attribute list now offersSupplier LotandHeat Number: it lists every name already used on any lot. Choose one to keep names consistent, or type a new one. - Clear Active and click Get lots to reload the table, widening the date range if your lots are older. Select the coated parts lot (
WCP000000000x) and addHardness (HRC),58.
- Select
RAL000000000xagain. Select theHeat Numberrow and click Edit Lot Attribute. - Change the value to
H58214and click Save. The table shows who created the attribute and when. - Double-click a row to see its whole value in a popup. That's useful for long values, such as notes or JSON from another system.
- Select the shipped package (
FGP000000000x). Show Full Lot Attributes is selected to start with, so its Lot Attributes tab lists the attributes of every lot linked to the package, with a lot # column: the aluminum's supplier lot and heat number, the coating's expiry date and the parts' hardness. - Clear Show Full Lot Attributes. The tab is now empty: you never added an attribute to the package itself. Select it again before you go on.
This is how attributes answer a customer question such as "which heat of aluminum is in this shipment?" without copying the heat number onto every lot along the way.
Add attributes where the information arrives: the supplier lot at receiving, the hardness at inspection. Don't copy them forward to the output lots; Show Full Lot Attributes and the trace already link them.
Lot Attributes in Scripts
Most lot attributes come from somewhere other than a person typing them: a receiving screen that scans the supplier's label, a gauge, an ERP or a lab system. Four functions cover them:
| Function | What it does |
|---|---|
system.kanoa.lot.getLotAttributes | Returns attributes filtered by lot, lot name, attribute name or value. Name and value filters are LIKE patterns, so % matches anything |
system.kanoa.lot.addLotAttribute | Adds an attribute to a lot |
system.kanoa.lot.updateLotAttribute | Changes an attribute, by its lotAttributeId |
system.kanoa.lot.deleteLotAttribute | Deletes an attribute, by its lotAttributeId |
addLotAttribute always adds a new row, even when the lot already has an attribute with that name. To keep one value per name, look for it first and update it if it's there:
def setLotAttribute(lotId, name, value, userId):
'''Adds the attribute, or updates it when the lot already has one with this name'''
info = {'lotId': lotId, 'lotAttributeName': name, 'lotAttributeValue': str(value)}
existing = system.kanoa.lot.getLotAttributes({'lotId': lotId, 'lotAttributeName': name})
if existing.rowCount:
info['lotAttributeId'] = existing.getValueAt(0, 'lotAttributeId')
return system.kanoa.lot.updateLotAttribute(info, userId)
return system.kanoa.lot.addLotAttribute(info, userId)
Each function returns a value and a message, and the message is None when it worked. Show the message to the user when it isn't.
-
In the Ignition Designer Script Console (Tools → Script Console), get a user ID and the
PRM-COATlot's ID. Replace thexwith your lot's number:userId = system.kanoa.security.getIDPUserId({'userName': 'SYSTEM'})lotId = system.kanoa.utilities.getFieldValue('lotId', system.kanoa.lot.getLots({'lotName': 'RBI000000000x'})) -
Paste
setLotAttributeand record the supplier lot:print setLotAttribute(lotId, 'Supplier Lot', 'PC-7731', userId). -
Run the same line again with
PC-7732. Check the Lot Attributes tab in Lot Manager: the lot has oneSupplier Lot, with the new value.
A supplier says its lot ALC-24-0917 was out of spec. Find your lot that came from it, then every lot linked to it:
data = system.kanoa.lot.getLotAttributes({'lotAttributeName': 'Supplier Lot', 'lotAttributeValue': 'ALC-24-0917'})
for row in system.dataset.toPyDataSet(data):
print row['lotName']
trace = system.kanoa.lot.traceLot(row['lotId'], 20)
print sorted(set(r['lotName'] for r in system.dataset.toPyDataSet(trace)))
- Run it in the Script Console. It finds your aluminum lot, then lists the lots linked to it.
- Compare the list with the aluminum lot's trace graph, at depth
D, from Execute the Trace.
After executeLotOperation creates the lot, look up its lotId with getLots and write the scanned supplier lot, expiry date and certificate number in the same button press, so a lot never exists without them.