Apr 6, 2016

Read PartyList types and items

It is not to say that PartyList data type in Activities are the most complex ones in Dyanmics CRM. They can be called as multi-lookups of multi types. I had to play a bit to understand how I am going to identify item with specific entity type and do something. Though of sharing the code; in this example, I am checking the attendee list of appointment and see if I have Contact type to do something with those items.

EntityCollection _ReqAttendees = _appointmentContext.GetAttributeValue<EntityCollection>("requiredattendees");
if ((_ReqAttendees != null) && (_ReqAttendees.Entities.Count > 0))
{
  foreach (var _party in _ReqAttendees.Entities)
  {
    if (_party.GetAttributeValue<EntityReference>("partyid").LogicalName == "contact")
    {
       // Do the work 
       // Contact ID : _party.GetAttributeValue<EntityReference>("partyid").Id
       
    }
  }
}

Hope this is helpful.

1 comment:

  1. This comment has been removed by a blog administrator.

    ReplyDelete