Показать сообщение отдельно
Старый 03.04.2014, 16:37   #7  
maksii is offline
maksii
Участник
 
15 / 16 (1) ++
Регистрация: 02.04.2014
Адрес: Харьков
Я сомневаюсь, что мой код будет работать, хотя вроде должен.

Ну а так, если я правильно понял:
Было:
Код:
if (!record.Contains("subject") || record["subject"].ToString() != uniq)
                {
                    uniq = string.Format("{0}", uniq.Length > uniqLength ? (uniq.Substring(0, uniqLength - 3) + "...") : uniq);
                    record["subject"] = uniq;
                    crmService.Update(record);
                }
Стало:

Код:
if (!record.Contains("subject") || record["subject"].ToString() != uniq)
                {
                    uniq = string.Format("{0}", uniq.Length > uniqLength ? (uniq.Substring(0, uniqLength - 3) + "...") : uniq);
                    record["subject"] = uniq;
                    if(executionContext.MessageName == MessageName.Update) 
                     {
                    crmService.Update(record);
                    }
                }
Ну и мой код должен выглядить как-то так, исходя из вашего класса:

Код:
            Entity yourEntityName = (Entity)executionContext.InputParameters["Target"];

            if(yourEntityName.Attributes.Contains("subject"))
            yourEntityName.Attributes["subject"] = yourEntityName.GetAttributeValue<EntityReference>("regardingobjectid").Name;
                    if(executionContext.MessageName == MessageName.Update) 
                    {
                    crmService.Update(yourEntityName );
                    }
Я только сомневаюсь, что у EntityReference имя референса называется Name