Skip to main content
Solved

How to create "LotSerialNbr" By code?


Hello,

I want to know if there are any solution to create the "LotSerialNbr" in SOShipLine By code.

Best regards.

Best answer by jknauf

Hello Mohamed,

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!

View original
Did this topic help you find an answer to your question?

2 replies

Forum|alt.badge.img
  • Varsity II
  • 35 replies
  • Answer
  • January 20, 2021

Hello Mohamed,

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!


  • Author
  • Jr Varsity II
  • 22 replies
  • January 21, 2021

Thank you @jknauf  for your helping, basically the analysis that you do, it works .


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings