bool HasRecordGraterThen1000 = true;
bool AddCustomeridCriteria = false;
// Create variables to store the last customer ID and Name returned by the GetCustomerList method.
string strLastCustomerNumber = “”;
string strLastCustomerName = “”;
HasRecordGraterThen1000 = false;
// Create the bank criteria object
customerCriteria = new CustomerCriteria();
AddCustomeridCriteria = false;
customerIDCriteria.GreaterThan = strLastCustomerNumber;
customerCriteria.Id = customerIDCriteria;
var customerSummaryList = wsDynamicsGP.GetCustomerList(customerCriteria, context);
if (customerSummaryList.Count() >= 1000)
HasRecordGraterThen1000 = true;
//Here you can process the data
// Obtain the customer Id and name of last customer returned.
strLastCustomerNumber = customerSummaryList[customerSummaryList.Length – 1].Key.Id;
strLastCustomerName = customerSummaryList[customerSummaryList.Length – 1].Name;
AddCustomeridCriteria = true;
What does above code do ? Let’s understand the code
First of all, there are variables declared with a default value. Now the while comes which will continue until it found HasRecordGraterThen1000 = true.
Now, within while we first set HasRecordGraterThen1000 to false, we assume that there is less then 1000 record.
For the first time, AddCustomeridCriteria is set to false so it will skip that if portion. Now API call will execute and will take data from Microsoft GP customer.
Next, if customerSummaryList has more than 1000 record we set variable HasRecordGraterThen1000 to true. as it more than 1000 now we set strLastCustomerNumber and AddCustomeridCriteria.
However, HasRecordGraterThen1000 is set to true it will execute while loop again and it will go in first if condition and set customerIDCriteria.And as it goes further it will load next record and skip first 1000 record.
Finally, This method is usefull in Microsoft GP Item List / Product List wsDynamicsGP.GetItemList,Microsoft GP Price List wsDynamicsGP.GetPricingList.
Note: This method will not work for Sales Order because by default sales order is order by Order No, and this order is not arranged in a proper manner because it saves all data in the same table.
I hope you liked my tiny help for .Net programming. Here is my other blog post for challenges in Microsoft GP.