Hi there
We need to zero the Qty. On Sales Order field in the item card. I wrote small code to update "Sales Line" table. Part of it below
SL.MODIFYALL("Outstanding Quantity", 0);
SL.MODIFYALL("Qty. to Invoice",0);
SL.MODIFYALL("Qty. to Ship",0);
SL.MODIFYALL("Outstanding Qty. (Base)", 0);
SL.MODIFYALL("Qty. to Invoice (Base)",0);
SL.MODIFYALL("Qty. to Ship (Base)",0);
Now, it successfully ZEROed all items. But, what I am worried about it is whether it will make any other area to work incorrectly. I dunno I am doing the correct thing.
Also, is there any other areas/tables I should update this information?
Please help me.
Thank you
Maluwa
Answers
Btw you should not write you code this way, you are not running the business logic.
The goal when you write code is to mimic how a you would do it manually.
The field on item card is a flowfield that looks for the sum of outstanding qty (base) on sales line.
So a user cannot see the outstanding qty (base) field on sales line. This field is calculated when you ship or change the qty field on sales order.
So you need to set the quantity field to what ever you have shipped.
Your code will loop through sales line.
SalesLine.setrange("No.",ItemNo);
salesline.setrange("Document type",order);
salesline.setrange(type,Item);
loop through it
//some things to work with. You have to reopen the order if it's released.
//validate the quantity to "Quantity shipped"
//Modify(true);
until salesline.next = 0;
By following how a user would do it, you are ensuring that you've followed the proper process and run the business logic, so you don't have to think on what else you have missed. And there could be a lot of things.
Serial no tables,
Lot no
reservation
warehouse shipments documents
the existing sales lines have base qty fields that are still the same.
oustanding amount fields on sales line
etc, etc
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
The reason for doing this is to plan on required qty on Sales Orders.
Our system has lot of pending orders (partially invoiced) and customer doen't neet them any more. We don't see a way to delete this pending orders from the Navision.
I actually did filter as you have done and but did not loop through Sales Line.
I don't fully understand the following lines from your code suggestion
How do I do this validation (will it make the "Outstanding Qty. (Base)" to zeo?) and what does modify(true) do. Please note that I am not an expert coder but have done customization to a certain extent.
On sales line, the Quantity=Outstanding quantity + Shipped Quantity but because you zeroed Outstanding quantity, it is not true and it can lead to problems in future. If you need to say "this line will not be shipped anymore", change the Quantity too (Quantity = Quantity - Outstanding Quantity) and do it with calling the Business logic (through Validate). Else you can have problems with reservations, tracking etc.
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
After a few trials, I now understand what you both have mentioned. I have modified the code and still testing it on a test DB. Once satisfied, I will post a reply here.
Thank you
you can't delete them?
http://www.BiloBeauty.com
http://www.autismspeaks.org
But, if I can follow the above method and update the lines, it is possible to DELETE them all.
You should be able to delete sales orders once the quantity shipped is equal to the quantity invoiced. If you have an order that has 10 shipped and 5 invoiced, then you need to invoice the remaining 5, and at that point you should be able to delete the sales order.
RIS Plus, LLC