2
votes

I've written the following code to query the ODATA endpoint in Dynamics Nav 2016. I did this by creating an ODATA connected service. I have passed a company name in the URL:

var navision = new Navision(
    new Uri("http://navision:7048/navision/OData/Company('Company1')"));

foreach (var foo in await navision.Foo.ExecuteAsync())
{
    Console.WriteLine(foo.Name);
}

Is it possible to query all companies in Navision? When I omit the /Company(...) section of the URL, I get an error:

DataServiceClientException: Cannot process the request because the default Microsoft Dynamics NAV company cannot be found. You can specify a default company in the service configuration file, or specify one for each tenant, or you can add a query string in the form of "company=[name]". You can see the available companies by accessing the default OData web service, Company. For more information, see "OData Web Services" in Help.

1
Nope. Different companies means different tables. Nav will not do join for you.Mak Sim
Put that as an answer @MakSim, :)Jake Edwards
Please investigate the System service to achieve this. This is a SOAP service, but I do not know if an equivalent one exists for OData?ian_scho

1 Answers

2
votes

Different companies means physically different tables on SQL with names like [dbo].[CompanyName$TableName]. Nav will not do join for you. If you are using tenants the tables will be even in separate per tenant databases.

So you need to query each company and then combine acquired data.