Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/unix/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Dynamics crm 2011 如何允许CRM插件处理多个事件消息_Dynamics Crm 2011_Dynamics Crm 2013_Dynamics Crm Online - Fatal编程技术网

Dynamics crm 2011 如何允许CRM插件处理多个事件消息

Dynamics crm 2011 如何允许CRM插件处理多个事件消息,dynamics-crm-2011,dynamics-crm-2013,dynamics-crm-online,Dynamics Crm 2011,Dynamics Crm 2013,Dynamics Crm Online,我需要创建一个插件,在创建、更新和删除商机实体的事件时启动 我可以在一个插件中完成这些操作吗?如果是这样的话,我该怎么做呢?您的插件必须实现Microsoft.Xrm.Sdk.IPlugin接口,该接口只有一个实现方法,Execute。在Execute方法中,需要检查IPluginExecutionContext的MessageName属性,并查看触发插件的事件类型。您还需要通过插件注册工具为每种消息类型(创建/更新/删除)注册插件 以下是我个人的OOB消息类型列表,可与MessageName进

我需要创建一个插件,在创建、更新和删除商机实体的事件时启动


我可以在一个插件中完成这些操作吗?如果是这样的话,我该怎么做呢?

您的插件必须实现
Microsoft.Xrm.Sdk.IPlugin
接口,该接口只有一个实现方法,
Execute
。在
Execute
方法中,需要检查IPluginExecutionContext的
MessageName
属性,并查看触发插件的事件类型。您还需要通过插件注册工具为每种消息类型(创建/更新/删除)注册插件

以下是我个人的OOB消息类型列表,可与
MessageName
进行比较:

AddItem,
AddListMembers,
AddMember,
AddMembers,
AddPrincipalToQueue,
AddPrivileges,
AddProductToKit,
AddRecurrence,
AddToQueue,
AddUserToRecordTeam,
Assign,
AssignUserRoles,
Associate,
BackgroundSend,
Book,
Cancel,
CheckIncoming,
CheckPromote,
Clone,
Close,
CopyDynamicListToStatic,
CopySystemForm,
Create,
CreateException,
CreateInstance,
Delete,
DeleteOpenInstances,
DeliverIncoming,
DeliverPromote,
DetachFromQueue,
Disassociate,
Execute,
ExecuteById,
Export,
ExportAll,
ExportCompressed,
ExportCompressedAll,
GenerateSocialProfile,
GrantAccess,
Handle,
Import,
ImportAll,
ImportCompressedAll,
ImportCompressedWithProgress,
ImportWithProgress,
LockInvoicePricing,
LockSalesOrderPricing,
Lose,
Merge,
ModifyAccess,
PickFromQueue,
Publish,
PublishAll,
QualifyLead,
Recalculate,
ReleaseToQueue,
RemoveFromQueue,
RemoveItem,
RemoveMember,
RemoveMembers,
RemovePrivilege,
RemoveProductFromKit,
RemoveRelated,
RemoveUserFromRecordTeam,
RemoveUserRoles,
ReplacePrivileges,
Reschedule,
Retrieve,
RetrieveExchangeRate,
RetrieveFilteredForms,
RetrieveMultiple,
RetrievePersonalWall,
RetrievePrincipalAccess,
RetrieveRecordWall,
RetrieveSharedPrincipalsAndAccess,
RetrieveUnpublished,
RetrieveUnpublishedMultiple,
RetrieveUserQueues,
RevokeAccess,
Route,
RouteTo,
Send,
SendFromTemplate,
SetRelated,
SetState,
SetStateDynamicEntity,
TriggerServiceEndpointCheck,
UnlockInvoicePricing,
UnlockSalesOrderPricing,
Update,
ValidateRecurrenceRule,
Win

是的,您可以使用相同的插件在创建、更新和删除时执行它

编写你的插件如下

    public void Execute(IServiceProvider serviceProvider)
    {
          IPluginExecutionContext context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));
           IOrganizationServiceFactory serviceFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
           IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId);

           if (context.MessageName == "Create") 
           {
             //write the logic what you want this plugin to do on Create
           }
           if (context.MessageName == "Update") 
           {
            //write the logic what you want this plugin to do on Update
           }
           if (context.MessageName == "Delete") 
           {
            //write the logic what you want this plugin to do on Delete
           }  
}
使用插件注册在创建、更新、删除Opper统一实体时注册插件 工具


它应该起作用

您的问题是否涉及使用单个插件来运行opportunity实体上的创建/更新/删除插件消息?您的问题标记为crm 2011,但crm 2013 sdk,是哪一个?请具体说明,并在问题描述中明确说明。