|
![]() |
#1 |
Kostya Afendikov
|
Да, бесконечный цикл был, да и вторая переменная оказалась лишняя, спасибо что указали. еще не набил руку.
Сделал Image на Post и событие и Зарегистрировал сборку на Update (Post) исправленный метод Execute X++: public void Execute(IPluginExecutionContext context) { DynamicEntity entity = null; if (context.PostEntityImages.Properties.Contains("Image")) { entity = (DynamicEntity)context.PostEntityImages.Properties["Image"]; if (entity.Properties.Contains("subject")) { if (entity.Properties["subject"].ToString() == "test1") { return; } } } else { throw new InvalidPluginExecutionException("Some sheet happened!"); } if (context.InputParameters.Properties.Contains(ParameterName.Target) && context.InputParameters.Properties[ParameterName.Target] is DynamicEntity) { entity = (DynamicEntity)context.InputParameters[ParameterName.Target]; } else { return; } try { Key entityId = new Key(); if (entity.Name == EntityName.task.ToString()) { if (entity.Properties.Contains("activityid")) { entityId = ((Key)entity.Properties["activityid"]); //entity = (DynamicEntity)context.InputParameters[ParameterName.Target]; DynamicEntity task = new DynamicEntity(); task.Name = EntityName.task.ToString(); task.Properties = new PropertyCollection(); task.Properties.Add(new StringProperty("subject", "test1")); task.Properties.Add(new KeyProperty("activityid", entityId)); ICrmService service = context.CreateCrmService(true); service.Update(task); } else { throw new InvalidPluginExecutionException("Entity image do not contains activityid field!"); } } } catch (System.Web.Services.Protocols.SoapException ex) { throw new InvalidPluginExecutionException( String.Format("An error occurred in the {0} plug-in.", this.GetType().ToString()), ex); } } |
|
![]() |
#2 |
Участник
|
Тоже столкнулся с какой то непонятной ошибкой при Update на плагине. Т.е. у меня написан плагин рабочий на Create, где он прекрасно работает, но когда я попробовал его переделать на Update он начал выводить ошибку "Данный ключ отсутствует в словаре", после операций с комментированием выяснилось что он ругается на начало
Цитата:
DynamicEntity entity = (DynamicEntity)context.InputParameters.Properties[ParameterName.Target];
string accountName = entity["name"].ToString(); string accountId = context.OutputParameters.Properties["id"].ToString(); ![]() |
|
![]() |
#3 |
Участник
|
Если не ошибаюсь, то на строчку
X++: string accountId = context.OutputParameters.Properties["id"].ToString(); |
|
![]() |
#4 |
Участник
|
А на строчку
X++: string accountName = entity["name"].ToString(); ![]() |
|
![]() |
#5 |
Участник
|
Цитата:
DynamicEntity entity = (DynamicEntity)context.PostEntityImages.Properties["Image"];
string accountName = entity.Properties["name"].ToString(); Так тоже не работает ![]() |
|
![]() |
#6 |
Участник
|
А Image точно зарегистрировано на Post и в нем есть атрибут name?
А не работает, что пишет, опять "Данный ключ отсутствует в словаре"? |
|
![]() |
#7 |
Участник
|
Да тоже самое пишет
![]() Цитата:
А Image точно зарегистрировано на Post и в нем есть атрибут name?
|
|
![]() |
#8 |
Участник
|
Для того чтобы использовать снимок состояния (Image), его нужно объявить в регистраторе плагинов, указав, какое состояние (Pre, Post или оба) вам собственно нужно и какие поля.
|
|
|
За это сообщение автора поблагодарили: Roman08 (1), Казарин Александр (1). |
|
![]() |
||||
Тема | Ответов | |||
PlugIn ImageEntity | 3 | |||
Доступ к custom fields в Plugin | 3 | |||
Получить id объекта вызвавшего PlugIn | 5 | |||
Закрыть задачи | 2 | |||
Письма в "Списки ожидания" - "Мои задачи" | 0 |
Опции темы | Поиск в этой теме |
Опции просмотра | |
|