Finding out what CRM data has changed since the last Web Services Interaction

1 minute read time.
If you use WebServices to query CRM Data then you may need to find out what data has changed since last update.

If you wish to find out what data has changed in CRM since a certain date then you can use

queryid

This is designed to return a set of id's based on a token date time, and is used for synching records.

The syntax looks like

queryid ( queryString As string , entityname As string , orderby As string , journaltoken As dateTime , showdeletedrecords As boolean ) As queryidresult

and an example of usage is below:

queryidresult entityQueryId = new queryidresult();
entityQueryId = WebService.queryid("comp_updateddate >= " + General.ConvertToSQLDate(DateTime.Now.Subtract(new TimeSpan(1, 0, 0))), "company", "comp_companyid", DateTime.Now.Subtract(new TimeSpan(1, 0, 0)), true);


A simpler method (queryidnodate) can be used if you just need to find data that matches a certain criteria.

queryidnodate ( queryString As string , entityname As string , showdeletedrecords As boolean ) As queryidnodateresult

The usage of queryidnodate looks like this (C#):

private void buttonQueryIDNoDate_Click(object sender, EventArgs e)
{
queryidnodateresult idList = CRM60.queryidnodate("comp_type='customer'", "company", false);
aisid[] myaisid = idList.records;
for (int intCount = 0; intCount
{
listBoxCompanyNames.Items.Add(myaisid[intCount].id);
}
}