Question

I am trying to count Qty_to_invoice in Purchase_Order_Line, but the value of this field is 0 at the very beginning, so I have to initialize it with Purchase Order Line's Quantity field. Problem is when it goes back to 0. How can I mark that all the invoices for this line are received?

I have found 'Finished' field in the Purchase_Order_Line, but I am not sure if I can use it. Can I? Can I? I am not sure what the system will use it for later...

Or just point me to the API documentation, if there is any, please. Something with description of all this fields would be great to read.

//ETDI: I use Web Services(Page) to access NAV.

Was it helpful?

Solution

but the value of this field is 0 at the very beginning, so I have to initialize it

I cant guess what exactly you are trying to do with Purchase Line, but fields like Qty. to Invoice and Qty. to Receive in most cases filled automatically when validating Quantity. Both sets equal to Quantity. Validate triggers when user enters something to field on the form or from C/AL code by calling PurcaseLine.VALIDATE("Quantyity", number);

Problem is when it goes back to 0. How can I mark that all the invoices for this line are received?

When you posting an invoice posted quantity is added to the field Qty. Invoiced and received quantity added to field Qty. Received. So at any time you know how many item received and payed. Both fields are readonly for user because only posting procedures can and must change those.

So if you have Qty. = 10, then you post 4 of them (Qty. to Invoice = 4) and Qty. Invoiced = 0. You'll get Qty. = 10, Qty. to Invoice = 6, Qty. Invoiced = 4. Qty. to Invoice in this case is rest of the qty. to be invoiced.

You shouldn't use any fields if you don't know their purpose. Field 'Finished' for example is part of Production Orders functionality and not related to Qty. to Invoice at all.

To find out meaning of a field you can refer to help (press F1 while standing on a field in table). That work not for every field. Another way (if you are developer and have license) is to use Developer Tool Kit (it can be found on installation CD or here). This utility allows to search for dependencies between Nav objects.


Regarding to web-services. Do not try to use those tables directly. Its really causes a lot of troubles and inconvenience. Create new operational tables. Name them Purchase Order Import and Purchase Line Import. Create pages for them and publish as web-services. Import your data into them in whatever you like format. I mean the tables can be clones of real tables or just have few fields you need. Put some code into OnModify trigger of the pages which will be called at the end of the import or publish codeunit with function that will create or update purchase orders and lines from Import-tables. Clear Import-tables after all.

If your task is to partially post receipts based on quantity from external system, then your steps will be:

  1. assume Purchase Order and Line created, Qty is 100, you need to post this qty in portions
  2. import Qty to be posted via web-service to Purchase Line Import table through page
  3. OnModify of the page will be triggered, put some code to that trigger to update Purchase Line's Qty. to Invoice -or- call some codeunit via web-service and update Purchase Line's Qty. to Invoice. Put all business logic on creating and updating purchase line here, not in your external application.
  4. Now you have Qty = 100, Qty to Invoice = 5.
  5. Call posting codeunit via web service. Of course don't publish posting codeunit itself. Call it through another codeunit that is published.
  6. Now you have Qty = 100, Qty to Invoice = don't really care, Invoiced Qty = 5, and you can repeat steps 2-5 again.

You shouldn't care about Qty to Invoice is thats why: next time you import next portion of qty all you need to check is Import_Qty < (Qty - Invoiced Qty). If true you can post, otherwise you cant.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top