*This post is locked for comments
I have the same question (0)Depends on where you'd want to apply this, but it would be something like this:
inventBatch.inventBatchId = codeforyourspecificformat;
inventBatch.itemId = _itemId;
// since you create it manually through code, it could result in a duplicate, so check this:
if (InventBatch::exist(inventBatch.itemId, inventBatch.inventBatchId))
error("Batchnumber already exists");
else
inventBatch.insert();
You can of course extend the filling of the other variables on the batch as you wish.