web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :

CRM 2016 – Get all activities related with a user with C#

Alessandro Graps Profile Picture Alessandro Graps 2,664

Today I need to get all activities related with a specific user. The way it to easy: We can use FetchXM or Query Expression. I usually prefer use Query Expression.
The code is easy:

private List<Entity> GetAssociatedActivities(EntityReference regarding)
        {
            QueryExpression query = new QueryExpression { EntityName = "activitypointer", ColumnSet = new ColumnSet(new string[] { "activitytypecode" }) };
            query.Criteria.AddCondition("regardingobjectid", ConditionOperator.Equal, regarding.Id);
            query.Criteria.AddCondition("statecode", ConditionOperator.NotEqual, 1);  //ignore completed
            EntityCollection collection = _sdk.RetrieveMultiple(query);
            return collection.Entities.ToList();
        }

That’s all.


Archiviato in:Microsoft Dynamics Crm Tagged: .Net, CRM, CRM2016, Microsoft Dynamics CRM, XRM

This was originally posted here.

Comments

*This post is locked for comments