I have a scenario, to find the records which are not shared with access team.
QueryExpression query = new QueryExpression("task")
{
ColumnSet = new ColumnSet("activityid", "subject", "customid"),
Criteria = new FilterExpression()
{
Conditions =
{
new ConditionExpression("customid", ConditionOperator.NotNull)
}
},
LinkEntities =
{
new LinkEntity("task", "principalobjectaccess", "activityid", "objectid", JoinOperator.Inner)
{
Columns = new ColumnSet(true),
EntityAlias = "POA",
LinkCriteria = new FilterExpression()
{
Conditions =
{
new ConditionExpression("principaltypecode", ConditionOperator.NotEqual, "team")
}
}
}
}
};
Result contains records which are shared and not shared.
principaltypecode value contains either SystemUser or Team, in my scenario I am expecting records which are not shared with any team.
Update: XrmToolBox has one plugin which helped me to find not shared records.
This plugin has the answer to my question but I need a c# Code to do this. Does anybody knows the mechanism of this tool to find such records?



You do not have direct way to retrieve Records which are not shared. But what you could do is
In this way you could get list or Account/Contact (Records) which are not shared