1
我正在嘗試將帳戶添加到約會的RequiredAttendees屬性中。我的代碼完美適用於電子郵件,傳真,信件。但在約會時創建時,不添加該屬性。如何將RequiredAttendees添加到CRM 2011中的約會中
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;
}