plugins - 如果报价成功关闭,则不会使用消息“win”触发 MS Dynamics CRM 插件
问题描述
环境是 Dynamics 365,当前版本。
我们有一个在赢得机会时触发的插件。一切都很好。但是,还有另一种方法可以结束机会,那就是通过相关报价。
如果您在相关报价中并执行“创建订单”,您也有机会关闭机会。但在这种情况下,插件不会触发消息“win”。
我假设事件在链中太深而不会触发。或者说这不是胜利事件,而是更新或某事。像那样。
有没有人有这个案子的经验?有什么意见吗?
Dot_NET Pro 问题的更新:
有一些 if 条件可以从代码中解救出来。第一个是:
public void Execute(IServiceProvider serviceProvider)
{
IOrganizationServiceFactory serviceFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
IPluginExecutionContext context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));
IOrganizationService organizationService = serviceFactory.CreateOrganizationService(null);
if (context.MessageName.ToLower() != "win")
{
return;
}
var currentOpportunity = RetrieveCurrentOpportunity(serviceFactory, context, organizationService);
if (currentOpportunity == null)
{
return;
}
// More code comes here.
第二个 if 进入具有此代码的方法:
private Entity RetrieveCurrentOpportunity(IOrganizationServiceFactory serviceFactory, IPluginExecutionContext context, IOrganizationService organizationService)
{
Guid opportunityId = Guid.Empty;
if (context.InputParameters.Contains("OpportunityClose") && context.InputParameters["OpportunityClose"] is Entity)
{ // ... more code here.
// else-case does nothing.
解决方案
通过在 UI 中创建订单来关闭机会不会触发实体机会上的获胜消息。显然应用层不使用WinOpportunityRequest
内部。它只是执行相关机会的更新(属性实际值、实际关闭日期和关闭概率)。
update
在实体“机会”的消息上注册您的插件。
(当报价丢失时,应用层实际上确实在LoseOpportunityRequest
内部使用。)
推荐阅读
- ruby-on-rails - 录像机:“目前没有磁带在使用。” 创建第二个磁带时
- apache-nifi - 如何从 nifi 的 s3 存储桶中读取镶木地板文件?
- r - 未能从客观问题中找出正确的替代方案
- docker - 将容器内的 Rest 调用转发到在主机上运行的 wiremock
- php - 留言簿不允许我匿名输入
- python - python 3.x 中的定义
- php - 如何从另一个网址随机显示元素?
- ruby-on-rails - 如何使用哈希语法访问 ruby 对象的方法?
- sharepoint - 在 SharePoint 库中按名称对文件进行分组
- c - 使用 scanf 和无字符串库函数的 C 回文