动态CRM - 确定联系人是否已在PreContactUpdate插件中合并

时间:2016-10-03 08:59:58

标签: c# plugins dynamics-crm-2011 microsoft-dynamics dynamics-crm-2015

我有一个插件,当联系人更新时会触发。当两个联系人合并时,这也会被触发。确定联系人是否已在PreContactUpdate插件中合并的最简单方法是什么?

代码:

    protected void ExecutePreContactUpdate(LocalPluginContext localContext)
    {
        if (localContext == null)
        {
            throw new ArgumentNullException("localContext");
        }

        Entity contact = (Entity)localContext.PluginExecutionContext.InputParameters["Target"];

        // check if contacts have been merged
        ....
    }

1 个答案:

答案 0 :(得分:2)

请尝试以下操作:

if (localContext.PluginExecutionContext.ParentContext != null &&
localContext.PluginExecutionContext.ParentContext.MessageName == "Merge")
{
//When records are merged
}
else
{
//All other cases
}