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

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.

One thought on “CRM 2016 – Get all activities related with a user with C#

  1. Pingback: Daily Cloud News Ignite Edition- Wed. Sept. 28, 2016 - enCloud9 - Dynamics CRM | Omaha | Arizona |California | Montana

Lascia un commento

Inserisci i tuoi dati qui sotto o clicca su un'icona per effettuare l'accesso:

Logo WordPress.com

Stai commentando usando il tuo account WordPress.com. Chiudi sessione / Modifica )

Foto Twitter

Stai commentando usando il tuo account Twitter. Chiudi sessione / Modifica )

Foto di Facebook

Stai commentando usando il tuo account Facebook. Chiudi sessione / Modifica )

Google+ photo

Stai commentando usando il tuo account Google+. Chiudi sessione / Modifica )

Connessione a %s...