I am trying to get all Customers created/updated after the value of a DateTime field.
In Dynamics CRM I would periodically call this method:
DateTime LastCheckedCRMAccount { get; set; }
private List<Account> GetCRMAccounts()
{
CRMLinq.ClearChanges(); // otherwise old data may be retrieved
IEnumerable<Account> accounts = from acc in CRMLinq.AccountSet
where acc.ModifiedOn > LastCheckedCRMAccount
select acc;
List<Account> accountList = accounts.ToList();
LastCheckedCRMAccount = DateTime.Now.ToUniversalTime();
return accountList;
}
This is what I have for Dynamics NAV at the moment:
DateTime LastCheckedNAVCustomer { get; set; }
private Customer[] GetNAVCustomers()
{
Customer_Filter filter = new Customer_Filter();
filter.Field = Customer_Fields.Last_Date_Modified;
filter.Criteria = LastCheckedNAVCustomer.ToString("ddMMyyyy") + "..";
Customer[] customers = nCustomer.ReadMultiple(new Customer_Filter[] { filter }, null, 0);
LastCheckedNAVCustomer = DateTime.Now;
return customers;
}
There does not seem to be a "ModifiedOn" field on the NAV customer table; there is a field named "Last Date Modified", but that only contains the date.
I would like to keep CRM Accounts up-to-date with NAV Customers.
Is there a better way to do this?