I need a c# code sample to read all customers from Dynamics Ax 2012 using aif service and display customer number, customer name alias, customer first name on console.
*This post is locked for comments
just for further requests:
you can achieve this by doing a service.find - operation with query criteria not equal empty.
For example:
CriteriaElement elem = new CriteraElement();
elem.DataSourceName = "CustTable";
elem.FieldName = "AccountNum";
elem.Operator = Operator.NotEqual;
elem.Value1 = "";
QueryCriteria crit = new QueryCriteria();
crit.CriteriaElement = new CriteriaElement[] { elem };
cust = custClient.find(context, crit);
Best regards
Lars
Thanks for the code. I have used the above code for getting the list of all customers but the number of customers I can get are 30, where as the total number of customers in the database are 271. Being a newbie, not sure what am I doing wrong. Would be great if you look at it and let me know.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using AIFQueryCriteria.ServiceReference1;
namespace AIFQueryCriteria
{
class Program
static void Main(string[] args)
ServiceReference1.CustomerServiceClient c1 = new ServiceReference1.CustomerServiceClient();
ServiceReference1.CriteriaElement elem = new ServiceReference1.CriteriaElement();
try
AxdCustomer cust = c1.find(null, crit);
for (int i = 0; i < cust.CustTable.Length ; i++)
Console.WriteLine(cust.CustTable[i].AccountNum.ToString());
Console.WriteLine(cust.CustTable[i].Name.ToString());
}
Console.ReadKey();
catch (Exception ex)
{ c1.Abort(); }
finally { c1.Close(); }
Check if you're getting data from the company you expect.
By the way, an alternative solution would be using the query service (your code is based on document services).
Under review
Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.
As AI tools become more common, we’re introducing a Responsible AI Use…
We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
Community Member 4
Nayyar Siddiqi 2
NNaumenko 2