locked
HOW CAN RUN DUPLICTAE DETECTION IN PLUGIN? RRS feed

  • Question

  • I CREATE NEW RECORD  USING PLUGIN
    HOW CAN RUN DUPLICTAE DETECTION BEFOR I CREATE  NEW RECORD
    Tuesday, September 29, 2009 11:27 AM

Answers

  • According to the SDK you can use the following code (which is a web based sample, not plugin one -> change the crmService instanciation)

    [C#]
    // 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);
    Tuesday, September 29, 2009 11:57 AM
    Moderator
  • Tanguy's code will work in a plugin, just make sure to use:

    var service = context.CreateCrmService(true);
    //before:

     


    // 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);

    Sunday, October 4, 2009 3:19 AM

All replies

  • According to the SDK you can use the following code (which is a web based sample, not plugin one -> change the crmService instanciation)

    [C#]
    // 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);
    Tuesday, September 29, 2009 11:57 AM
    Moderator
  • Tanguy's code will work in a plugin, just make sure to use:

    var service = context.CreateCrmService(true);
    //before:

     


    // 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);

    Sunday, October 4, 2009 3:19 AM