环境是Dynamics 365,当前版本。
我们有一个插件,它在赢得机会时被触发。一切都很好。但是,还有另一种方法来结束赢得的机会,那就是通过相关的报价。
如果你在一个相关的报价和做“创建订单”,你有机会关闭的机会,以及赢得。但在这种情况下,插件不会触发消息“win”。
有人经历过这个案子吗?有什么意见吗?
更新Dot\u NET Pro的问题:
第一个是:
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.