Tuesday, May 11, 2010

ActivityParty Property Con't

Last month I made a post about grabbing an ActivityParty property from a DynamicEntity and recently someone on the CRM forums made a post asking how to add an ActivityParty property to a DynamicEntity.  This can be very confusing and not straightforward at all so I'm going to post the snippet that I answered with in hopes to help some people out.

            DynamicEntity email = new DynamicEntity("email");
            // setup email attributes

            DynamicEntity contactParty = new DynamicEntity("activityparty");
            contactParty.Properties.Add(new LookupProperty("partyid", new Lookup("contact", new Guid("Contact ID"))));

            email.Properties.Add(new DynamicEntityArrayProperty("to", new DynamicEntity[] { contactParty}));

Note:  Shan McArthur replied to the post on the forum saying that this becomes easier with the new XRM dlls from the latest SDK.  Hopefully I can play around with these new dlls soon and be able to post some updated snippets.

No comments:

Post a Comment