![]() |
#6 |
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); } } |
|
|
![]() |
||||
Тема | Ответов | |||
PlugIn ImageEntity | 3 | |||
Доступ к custom fields в Plugin | 3 | |||
Получить id объекта вызвавшего PlugIn | 5 | |||
Закрыть задачи | 2 | |||
Письма в "Списки ожидания" - "Мои задачи" | 0 |
|