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

Discussions relating to plugin development, and the Jiwa API.

Timing when line is finished adding to set the OrderQty

Postby DannyC » Tue Jan 11, 2022 6:09 pm

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?
User avatar
DannyC
Senpai
Senpai
 
Posts: 638
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 30

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

Postby SBarnes » Thu Jan 13, 2022 10:37 am

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.
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1621
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 176

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

Postby Mike.Sheen » Thu Jan 13, 2022 10:56 am

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.
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2445
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 757

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

Postby DannyC » Thu Jan 13, 2022 11:34 am

You want to handle the AddInventoryItemEnd event of the SalesOrderLines instead


Beautiful. That did it. Thx again.
User avatar
DannyC
Senpai
Senpai
 
Posts: 638
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 30


Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 12 guests