动态实体的 RetrieveDuplicatesRequest

发布于 2024-11-30 20:41:12 字数 327 浏览 2 评论 0原文

需要建议,我正在检索我创建的自定义实体的重复记录的 GUID。但是我研究和发现的代码正在使用 CRM 业务实体:

RetrieveDuplicatesRequest request = new RetrieveDuplicatesRequest();
request.BusinessEntity = lead;
request.MatchingEntityName = EntityName.lead.ToString();
request.PagingInfo = new PagingInfo();

任何人都可以为我提供动态实体的链接或帮助吗?

谢谢

Need advice, I am retrieving GUID for the duplicate Records for a customise entity that i have created.However code that i research and found is using CRM business Entity:

RetrieveDuplicatesRequest request = new RetrieveDuplicatesRequest();
request.BusinessEntity = lead;
request.MatchingEntityName = EntityName.lead.ToString();
request.PagingInfo = new PagingInfo();

could anyone provide me the link or help for dynamic entity?

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

橘虞初梦 2024-12-07 20:41:12

首先要检查的是您的自定义实体是否在自定义实体屏幕中启用了重复检测。如果没有,请将其打开并发布实体,然后从 SDK 继续处理此代码。此代码将根据帐户名称搜索重复的帐户。

// Set up the CRM service.
CrmAuthenticationToken token = new CrmAuthenticationToken();
token.AuthenticationType = 0; 
token.OrganizationName = "AdventureWorksCycle";

CrmService service = new CrmService();
service.Url = "http://<servername>:<port>/mscrmservices/2007/crmservice.asmx";
service.CrmAuthenticationTokenValue = token;
service.Credentials = System.Net.CredentialCache.DefaultCredentials;

// Create the account instance and set the name property.
account acct = new account();
acct.name = "Microsoft";

// Create the request object.
RetrieveDuplicatesRequest Request = new RetrieveDuplicatesRequest();
Request.BusinessEntity = acct;
Request.MatchingEntityName = EntityName.account.ToString();
Request.PagingInfo = new PagingInfo();

// Execute the request.
RetrieveDuplicatesResponse Response = 
    (RetrieveDuplicatesResponse) Service.Execute(Request);

如果您想通过上述代码使用动态实体,只需实例化动态实体而不是创建帐户的行,然后在 Request 对象上将“ReturnDynamicEntities”设置为 true 即可。如果您正在寻找一种方法来开始在整个数据库中搜索重复项,而不是询问特定记录是否重复,请使用以下代码:

// Set up the CRM Service.
CrmAuthenticationToken token = new CrmAuthenticationToken();
// You can use enums.cs from the SDK\Helpers folder to get the enumeration for Active     Directory authentication.
token.AuthenticationType = 0; 
token.OrganizationName = "AdventureWorksCycle";

CrmService service = new CrmService();
service.Url = "http://<servername>:<port>/mscrmservices/2007/crmservice.asmx";
service.CrmAuthenticationTokenValue = token;
service.Credentials = System.Net.CredentialCache.DefaultCredentials;

// Create a query expression for the bulk duplicate detection.
QueryExpression query = new QueryExpression();
query.EntityName = EntityName.account.ToString();

// Create the request (do not send an e-mail).
BulkDetectDuplicatesRequest request = new BulkDetectDuplicatesRequest();
request.JobName = "Detect Duplicate Accounts";
request.Query = query;
request.RecurrencePattern = string.Empty;
request.RecurrenceStartTime = new CrmDateTime();
request.RecurrenceStartTime.Value = DateTime.Now.ToString("s");
request.SendEmailNotification = false;
request.ToRecipients = new Guid[0];
request.CCRecipients = new Guid[0];
request.TemplateId = Guid.Empty;

// Execute the request.
BulkDetectDuplicatesResponse response = (BulkDetectDuplicatesResponse)service.Execute(    request);
Guid jobId = response.JobId;

这是使用 BulkDetectDyplicates 消息。这应该会让你走上正确的道路。

The first thing to check is that your custom entity has duplicate detection enabled in the customize entity screen. If it doesn't, turn it on and publish the entity, then move on to this code from the SDK. This code will search for a duplicate account based on the account name.

// Set up the CRM service.
CrmAuthenticationToken token = new CrmAuthenticationToken();
token.AuthenticationType = 0; 
token.OrganizationName = "AdventureWorksCycle";

CrmService service = new CrmService();
service.Url = "http://<servername>:<port>/mscrmservices/2007/crmservice.asmx";
service.CrmAuthenticationTokenValue = token;
service.Credentials = System.Net.CredentialCache.DefaultCredentials;

// Create the account instance and set the name property.
account acct = new account();
acct.name = "Microsoft";

// Create the request object.
RetrieveDuplicatesRequest Request = new RetrieveDuplicatesRequest();
Request.BusinessEntity = acct;
Request.MatchingEntityName = EntityName.account.ToString();
Request.PagingInfo = new PagingInfo();

// Execute the request.
RetrieveDuplicatesResponse Response = 
    (RetrieveDuplicatesResponse) Service.Execute(Request);

If you want to use a dynamic entity with the above code, just instantiate a dynamic entity instead of the lines that make an account, and set 'ReturnDynamicEntities' to true on the Request object. If you were looking for a way to start searching the entire database for duplicates rather than asking if a specific record is a duplicate, here is the code:

// Set up the CRM Service.
CrmAuthenticationToken token = new CrmAuthenticationToken();
// You can use enums.cs from the SDK\Helpers folder to get the enumeration for Active     Directory authentication.
token.AuthenticationType = 0; 
token.OrganizationName = "AdventureWorksCycle";

CrmService service = new CrmService();
service.Url = "http://<servername>:<port>/mscrmservices/2007/crmservice.asmx";
service.CrmAuthenticationTokenValue = token;
service.Credentials = System.Net.CredentialCache.DefaultCredentials;

// Create a query expression for the bulk duplicate detection.
QueryExpression query = new QueryExpression();
query.EntityName = EntityName.account.ToString();

// Create the request (do not send an e-mail).
BulkDetectDuplicatesRequest request = new BulkDetectDuplicatesRequest();
request.JobName = "Detect Duplicate Accounts";
request.Query = query;
request.RecurrencePattern = string.Empty;
request.RecurrenceStartTime = new CrmDateTime();
request.RecurrenceStartTime.Value = DateTime.Now.ToString("s");
request.SendEmailNotification = false;
request.ToRecipients = new Guid[0];
request.CCRecipients = new Guid[0];
request.TemplateId = Guid.Empty;

// Execute the request.
BulkDetectDuplicatesResponse response = (BulkDetectDuplicatesResponse)service.Execute(    request);
Guid jobId = response.JobId;

This is using the BulkDetectDyplicates message. This should get you headed on the right path.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文