We covered a few Synchronization topics in the last few blogs, here we will look at defining system filters to manage which records could be synced.
How to – Synchronize Appointments between Dynamics 365 and Outlook using Server-Side Synchronization
How are tasks, letters, fax, phone call synchronized between Dynamics 365 and Outlook
We can see few default User Filters already defined that syncs records owned by the current user.
Users can create new filters, edit the existing filters, delete, activate, deactivate and reset the filters.
These filters like personal filters applied to that particular user only.
The same can also be accessed from Personalization Settings
Personal Options > Synchronization tab
Similar to User Filters we can define System Filters that apply to the entire organization or all the users.
As we can see there are no options (no new button) to create new System Filters from the user interface. The only way we can create them is through SDK.
Suppose we don’t want any tasks to be synced.
For this, we can create a filter like “sync only those tasks where created on doesn’t have value” which will always evaluate to false.
On executing the below code
We can see the system filter created successfully.
Hope it helps..
Entity savedQuery = new Entity("savedquery");
savedQuery.Attributes["name"] = "System Filter for Task";
savedQuery.Attributes["description"] = "To restrict sync of tasks";
savedQuery.Attributes["isquickfindquery"] = false;
// saved query is of type outlook fiter
savedQuery.Attributes["querytype"] = SavedQueryQueryType.OutlookFilters;
savedQuery.Attributes["returnedtypecode"] = "task";
// sync only those tasks which have created on as null
// this is to restrict task sync
savedQuery.Attributes["fetchxml"] =
@"<fetch>" +
"<entity name='task'>"+
"<attribute name='activityid'/>" +
"<filter>" +
"<condition attribute='createdon' operator='null'/>" +
"</filter>" +
"</entity>" +
"</fetch>";
var response= svc.Create(savedQuery);
3 thoughts on “How to – Define System Filters for Synchronization using SavedQuery in Dynamics 365 / CRM”