Page 1 of 1

Timing when line is finished adding to set the OrderQty

PostPosted: Tue Jan 11, 2022 6:09 pm
by DannyC
When a sales order line is added, some unique items need a particular QuantityOrdered when the line is added.

I have tried both events
Code: Select all
soForm.SalesOrder.SalesOrderLines.Added += Attkey_SOLineAdded;
soForm.SalesOrder.SalesOrderLineAdded += Attkey_SOLineAdded2;


but they set the QuantityOrdered to 1 even though I have the following code to set 3.
Code: Select all
int myQty = 3;
soLine.QuantityOrdered = myQty;


I'm suspecting that it might be a timing issue - like the line hasn't completely finished getting added to the grid & I am setting the value but then it gets overwritten with the system DefaultQuantity. What's the best way to force the QuantityOrdered as the line is getting added?

Re: Timing when line is finished adding to set the OrderQty

PostPosted: Thu Jan 13, 2022 10:37 am
by SBarnes
What does the actual sales order line have as the quantity?

You may find you need to call DisplayLine on the actual form.

What I am saying is firstly check that you event is firing then check what the object holds, it could simply be you need to refresh the display of the grid as both the line added and line changed events on the form do this.

Re: Timing when line is finished adding to set the OrderQty  Topic is solved

PostPosted: Thu Jan 13, 2022 10:56 am
by Mike.Sheen
We set the QuantityOrdered inside the AddInventoryItem method AFTER it is added to the collection - it is set to SystemSettings.DefaultQuantity.

You want to handle the AddInventoryItemEnd event of the SalesOrderLines instead. This event is raised at the very end of the AddInventoryItem method.

Re: Timing when line is finished adding to set the OrderQty

PostPosted: Thu Jan 13, 2022 11:34 am
by DannyC
You want to handle the AddInventoryItemEnd event of the SalesOrderLines instead


Beautiful. That did it. Thx again.