Показать сообщение отдельно
Старый 09.08.2012, 15:52   #14  
probka is offline
probka
Участник
Аватар для probka
 
98 / 11 (1) +
Регистрация: 20.02.2012
Адрес: Ростов-на-Дону
Цитата:
Сообщение от a33ik Посмотреть сообщение
Код плагина дайте ещё на всякий случай, пожалуйста. Точнее больше интересует конструктор.
X++:
        public void Execute(IPluginExecutionContext context)
        {
            if (!(context.InputParameters.Contains("Target")) || !(context.InputParameters["Target"] is DynamicEntity))
                return;

            DynamicEntity _opportunity = (DynamicEntity)context.InputParameters["Target"];

            if (_opportunity.Name != EntityName.opportunity.ToString())
                    return;

            if (!_opportunity.Properties.Contains("new_status"))
                return;

            Picklist status = (Picklist)_opportunity["new_status"];

            if (status.Value.ToString() != "5")
                return;

            ICrmService crmService = context.CreateCrmService(true);

            DynamicEntity new_stop = new DynamicEntity("new_stop");

            Customer oppid = (Customer) _opportunity["opportunityid"];

            Lookup oppLookup = new Lookup();
            oppLookup.Value = oppid.Value;
            oppLookup.type = EntityName.opportunity.ToString();

            new_stop.Properties.Add(new LookupProperty("new_contractid", oppLookup));

            Guid stopGuid = crmService.Create(new_stop);

        }
__________________
Так победим!