I want to know if there are any solution to create the "LotSerialNbr" in SOShipLine By code.
Best answer by jknauf
First off, you shouldn’t think about this as “creating” this field. You could create rows for the table, but I’m pretty sure you want to modify existing data. That field already exists, the value it holds is just null.
Anyway I’d say the first step to doing so would be to determine where you’re going to do this, meaning what graph you’re going to extend. This is important as it defines when your code triggers and what objects/views you have available to you. This should really be dictated by when you want your code to trigger. Generally each screen has it’s own graph, and then you can define event handlers to get more specific as to when this code triggers.
So once you find where you want this code, the next step is getting a reference to the SOShipLine object. Unfortunately how you do this is going to be dependent on the graph you pick, so I can’t just give you the code without knowing it’s context, but I’ll try to give a relatively generic example.
Let’s say you have the variables shipNbr which holds the SOShipLine.ShippmentNbr and line which holds SOShipLine.LineNbr for the record you’d like to change. Your code should look something like this:
// BQL statement to get instance of SOShipLine object
var shipLine = new PXSelect<SOShipLine, Where<SOShipLine.lot.shipmentNbr, Equal<Required<SOShipLine.shipmentNbr>>, And<Where<SOShipLine.lineNbr, Equal<Required<SOShipLine.lineNbr>>>>>>(this.Base).SelectSingle(shipNbr, line);
// Set the value of LotSerialNbr
shipLine.LotSerialNbr = "My lot serial number";
Hopes this helps! Have a happy development!