Я сомневаюсь, что мой код будет работать, хотя вроде должен.
Ну а так, если я правильно понял:
Было:
Код:
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