Can I call a Code Unit which is published as a web service from Navision ? without C# code

Is this possible ?

Yes you Can as web services are published with company name…
So if you want to run a webservice for company B from Company A, yes its possible because URL will be in format -


Hi :),
So, How can I call it from my code?
Lets say I have a CU which take a rec as a Parameter and this CU is Published as a web service.

The Codeunit that you are referring from Vjeko Babic’s have a function connect that should do the magic.
I haven’t actually used it but i know it can be done.

You read my mind. I used it and its Perfect only with the English Language. with the German language its totally not stable.

I would say I have only one chance which is:

  1. Create the Code unit
  2. Publish it as a Web service
  3. Create a C# class ---------> I will follow this (…/dd339004(v=nav.90).aspx))
  4. Now callling the code unit from my Navision code ???

This is the setp which I am not able to understand till now. Lets say I have an Action button and I want this action button to call the web service. can you provide me with some tips how to make this possible? :slight_smile:

I don’t think you need to do a step 3.

i would suggest first test with a simple example like -

  1. Create a table with some test fields.
  2. create a codeunit with code that it creates records in table.
  3. Now publish that web service.
  4. From another company copy Web service URL for the same codeunit and then from company 1 use connect with that URL from company 2.
    If that works then you can proceed what you want.

The only Problem with Vjeko solution is that if you click diffrent time on the Page the code will fire an error. That Why I donot want to use it anymore. I was really happy using in in the last two days but now after 2 days of hard testing its not stable.

Thats why I want to use the C# class in order to make sure that I have 100% stable solution.

I tried to Run this Code unit from Company 1, which should results in an entry in company 2. but its not working :frowning:

ResultTable.ID := ‘1’;
ResultTable.Name := ‘Mohamed’;
ResultTable.Company_Name := ‘Herstellung’;
ResultTable.AttempTime := TIME;
ResultTable.Counter := 1;



No this is not the right way to do it.

  1. You need two codeunits.
    a) one which is configured as webservice and that have init and insert in onrun trigger.
    b) second which call that codeunit using connect. Connect actually executes the command in that codeunit as per the company in URL.

Its not working, Are you sure 100% that calling the link with the connect function will trigger the CU?

But even IF it work I need to pass a Parameter to the CU. How would you do this, I guess the have to follow the C# approach ? or what you think?

Give it a try man…
As i will get some free time, i will check the approach which i am suggesting.