我期待爲我的創建插件的實體「帳戶」設計一些邏輯。如何使用Dynamics CRM 2011中的插件識別重複記錄
它的功能基本上是檢查帳戶名稱和標識創建時重複的帳戶名稱。
所以,如果有一個帳戶名稱,巴克萊例如,我嘗試再次創建這個我要提醒用戶一個錯誤消息,這已創建之前,並防止添加此記錄。
public void Execute(IServiceProvider serviceProvider)
{
var context = (IPluginExecutionContext)serviceProvider.GetService(typeof(Microsoft.Xrm.Sdk.IPluginExecutionContext));
if (context.InputParameters.Contains("Target") &&
context.InputParameters["Target"] is Entity)
{
// Obtain the target entity from the input parmameters.
Entity entity = (Entity)context.InputParameters["Target"];
if (entity.LogicalName == "account")
{
bool x = true;
if (entity.Attributes.Contains("Name") != recordNamesinCRM)
{
}
else
{
throw new InvalidPluginExecutionException("You Cannot Have Duplicate Country Codes!.");
}
}
}
}
在上面的代碼我只是用「recordNamesinCRM」作爲一個例子,但我敢肯定有一個內置的功能或比較上與系統或方法的其餘部分創建一個新名稱的方式計算重複出現的實例。
您是否找到了解決方案?最後,我正在尋找基於聯繫人實體中唯一的電子郵件地址字段進行類似的操作 – Andrew 2011-11-30 22:20:12