Показать сообщение отдельно
Старый 23.07.2012, 21:01   #1  
Taker1796 is offline
Taker1796
Участник
Аватар для Taker1796
 
112 / 11 (1) +
Регистрация: 22.04.2012
Плагин не срабатывает на Delete crm 2011
Привет! Есть плагин, работает на update и на create, а вот на Delete не срабатывает. Зарегистрирован на Pre. Суть его работы в подсчете числа юзеров.


public void RetrieveCountContacts(IServiceProvider serviceProvider)
{
int Count = 0;
IPluginExecutionContext context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));
if (context.InputParameters.Contains("Target") && context.InputParameters["Target"] is Entity)
{
entity = (Entity)context.InputParameters["Target"];
}
IOrganizationServiceFactory serviceFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId);

......//условия поиска по связи 1:N
foreach (var a in result.Entities)
{
Count++;
}

if(context.MessageName=="Delete")
{
Count--;
}