Navision WebService, ReadMultiple and DataSet

Dear frends,

I face one issue regarding consuming DynamicsNAV services for which do not know ansewr.
Namely, I want to make one web service which use standard DynamicsNAV services to read data and than with Data Set to return that data.

This is web service should to pickup data about all Customers which Location Code is RED and then to return that in Data Set.
But my output here is empty.
Can somebody tell me where is problem with this code and why data set is empty.

Thanks in advance.

[WebMethod]
public DataSet ReadNAVCustomers()
{
Customer.Customer_Service service = new Customer.Customer_Service();

service.Url = “http://localhost:7047/DynamicsNAV/ws/CRONUS_International_Ltd/Page/Customer”;
service.UseDefaultCredentials = true;

Customer.Customer_Filter filter = new Customer.Customer_Filter();
filter.Field = Customer.Customer_Fields.Location_Code;
filter.Criteria = “RED”;

Customer.Customer[] customers = service.ReadMultiple(new Customer.Customer_Filter[] {filter},null,0);

DataSet ds = new DataSet();
DataRow dr;
DataTable dt = ds.Tables.Add(“Customer”);

DataColumn dc = new DataColumn(“VALUE”, Type.GetType(“System.String”));
dt.Columns.Add(dc);

foreach (Customer.Customer Customer1 in customers)
{
dr = dt.NewRow();
dr[“VALUE”] = Customer1.Name.ToString();
}

return ds;

}

}

Hi,

I think it might be something to do with your readmultiple command. The last parameter you’re passing is the set size, and you have 0. Try something like this instead.

Customer.Customer[] customers = service.ReadMultiple(new Customer.Customer_Filter[] {filter},null,100);

Thanks Michael for you quick response. :slight_smile:

I found the error … the filter does work. My option field was not updated for some reason.

Customer customer = new Customer() { No = “TEST 1”, Name = “Test 1”, Contact = “khanh”, Blocked = Blocked .Ship };

custService.Create(ref customer);

Any idea?

Thanks

KL

If thats the case then your filter is dodgy, and you should experiment with it a little more. All of my filters work perfectly and only return the records I’m looking for. What does your code look like?

My example is below (c#) for a webservice called ‘SyncJobTask’. Try declaring and using the filter like I have below.

SyncJobTask_Service NavWebS = new SyncJobTask_Service();

NavWebS.UseDefaultCredentials = true;
NavWebS.Url = NavUrl + “/Page/SyncJobTask”;

List<SyncJobTask_Filter> filter = new List<SyncJobTask_Filter>();
SyncJobTask_Filter nameFilter = new SyncJobTask_Filter();
nameFilter.Field = SyncJobTask_Fields.Exported;
nameFilter.Criteria = “No”;
filter.Add(nameFilter);

SyncJobTask[] list = NavWebS.ReadMultiple(filter.ToArray(), null, 0);

foreach (SyncJobTask j in list)
{

// do whatever

}