Post purchase order from web service

Hi all,

I am quite new to navision. I am trying to update a purchase order through a web service. I can modify it easily from c# through Purchase order page (50) as a web service, but so far I have to then log in to Navision to post the page/recieve the items.

How would one go about doing this through a web service?

You can expose the Codeunit as a Web Service as well (Codeunit 90) and call it. Or you could create a function on the Page that posts the order (base page uses the RunObject property) and call it from your existing web service.

If I may ask, to learn, which method would you use, and why?

Generally it is best practice to not put code on Pages or Forms, but this one is pretty small and is in fact only one line that makes a call to a Codeunit.

If you plan to be able to post other types of purchase documents from a web service I would expose the Codeunit. If you are just going to post order I would leave it in the page. It is probably easier to leave it in the page if you are going for the quick solution.

Sounds logical, thank you.

One more question, are there any pages that call codeunits already in Navision so I can study code?

Just about every page out there. Look at the Reopen function on the Purchase Order for quick example.

Don’t forget to verify the post if you feel the topic has been solved. Good luck.

The only functions for this page are:


Am I missing something?

You have to make your own function that calls the posting routine if that is what you are looking for. There is not an existing function to do it. If you look at the action for the Post button you’ll see the code behind it. You need to replicate this code in your new function.

Check whether this helps you

I am (almost) posting PO but get error “Please enter “Yes” in Receive and/or Invoice and/or Ship”

Where do I enter this as I can’s seem to find the field

If you do it in NAV while posting the PO, you will get a window to chose either to (ship) or (invoice) or (ship and invoice)…

may be You need to pass this before posting in webservices…

You can find it in above link…

For an example, for Sales Posting I have write a function to call standard posting Codeunit with 4 parameters as per below:

  1. Document Type
  2. Document No
  3. Ship (Boolean)
  4. Invoice (Boolean)

Start by looking at the code behind the post button. First it calls a Post (Yes / No) Codeunit, which then calls the post codeunit. Go through the code in the debugger (or by yourself), line by line, step by step, to see what objects get used, where the user would have to interact. You’ll want to call the same code and take appropriate actions on behalf of the user if they need to do anything (like pick between Receive, Invoice, and Receive and Invoice).

Thanks for the help

I finally understood process.