domingo, 15 de septiembre de 2013

CRM 4 - Trabajar con el campo ActivityParty en entidades dynamicas

First, I establish a DynamicEntity of the activityparty type:
DynamicEntity activityParty = new DynamicEntity("activityparty");


Then, I create a new LookupProperty for the partyid attribute of our new activityparty entity, and set it to our customerId variable:
LookupProperty partyProperty = new LookupProperty("partyid", new Lookup(EntityName.account.ToString(), customerId));
activityParty.Properties.Add(partyProperty);


Finally, I create a new DynamicEntityArrayProperty for the customers attribute of my Service Activity, and load our activityParty into it as a DynamicEntity array:
DynamicEntityArrayProperty customersProperty = new DynamicEntityArrayProperty("customers", new DynamicEntity[] { activityParty });
serviceActivity.Properties.Add(customersProperty);


---------------------------------------Ejemplo-----------------------------------------------

partyProperty = new LookupProperty("partyid", new Lookup(EntityName.systemuser.ToString(), new Guid("047D5926-3A79-DF11-A35E-005056A9638C")));
activityParty.Properties.Add(partyProperty);
usersProperty = new DynamicEntityArrayProperty("from", new DynamicEntity[] { activityParty });
email.Properties.Add(usersProperty);
activityParty = new DynamicEntity("activityparty");
fromProperty = new StringProperty("addressused", "a@a.es");
activityParty.Properties.Add(fromProperty);
usersProperty = new DynamicEntityArrayProperty("to", new DynamicEntity[] { activityParty });
email.Properties.Add(usersProperty);

No hay comentarios:

Publicar un comentario