hello B
hello B

Reputation: 963

how to add RequiredAttendees to Appointment in crm 2011

I'm trying to add account to RequiredAttendees attribute of an appointment. My code works perfectly on email, fax, letter. But on appointment when is created, doesn't add the the attribute.

 string[] ToArr = new string[1];
            Guid To = Guid.Empty;
            try
            {
                if (Utility.To.Contains(";"))
                {
                    ToArr = Utility.To.Split(';');
                }
                else
                {
                    ToArr[0] = Utility.To;
                }

                EntityCollection collToParty = new EntityCollection();
                for (int i = 0; i < ToArr.Length; i++)
                {
                    if (Guid.TryParse(ToArr[i].ToString(), out To))
                    {

                        EntityReference to = new EntityReference(Utility.Toguidentityname, To);
                        Entity toParty = new Entity("activityparty");
                        toParty.Attributes.Add("partyid", to);
                        collToParty.EntityName = Utility.Toguidentityname;
                        collToParty.Entities.Add(toParty);
                    }
                    else
                    {
                        throw new Exception("Il valore del campo della stringa " + To + " toGuid non è un GUID:" + ToArr[i].ToString());

                    }
                }

                if (entity.LogicalName.Equals("appointment"))
                    entity.Attributes.Add("RequiredAttendees", collToParty);
                else
                    entity.Attributes.Add("to", collToParty);

            }
            catch (Exception ex)
            {
                LoggerObj.writeLog("Errore:" + ex.Message);
                throw;
            }

Upvotes: 1

Views: 1037

Answers (1)

Guido Preite
Guido Preite

Reputation: 15128

try to lowercase RequiredAttendees:

entity.Attributes.Add("requiredattendees", collToParty);

Upvotes: 1

Related Questions