我期待为我的创建插件的实体“帐户”设计一些逻辑。如何使用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