Microsoft Dynamics Nav: Retrieving a set of Records through Web Services
In a previous post ( Microsoft Dynamics Nav: Using an XMLPort as a .NET DataSource and Microsft Dynamics Nav: Export XMLPort to File) I had demonstrated how to return a set of records, using Web Services, from Microsoft Dynamics Nav with an XMLPort as a dataset.

The following example demonstrates returning a filtered set of records from Microsoft Dynamics Nav through Services.
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
GetCustomers_Binding ws;
Customers customers;
BindingSource bs;
private void Form1_Load(object sender, EventArgs e)
{
ws = new GetCustomers_Binding();
ws.UseDefaultCredentials = true;
ws.Url = "http://localhost:7047/DynamicsNAV/WS/CRONUS%20USA,%20Inc./Codeunit/GetCustomers";
customers = new Customers();
bs = new BindingSource();
BindData(textBox1.Text);
}
private void BindData(string salespersoncode)
{
ws.GetCustomers(salespersoncode, ref customers);
dataGridView1.DataSource = bs;
bs.DataSource = customers.Customer;
}
private void button1_Click(object sender, EventArgs e)
{
BindData(textBox1.Text);
}
}
![GetCustomers(SalesPerson : Code[10];VAR CustXML : XMLport Customer_Export) IF SalesPerson <> '' THEN Customer.SETRANGE("Salesperson Code",'PS'); CustXML.SETTABLEVIEW(Customer);](/blog/image.axd?picture=2011%2f9%2fgercustomers_2.png)
The sample application referenced in this post can be downloaded >>>here<<<.