locked
Crm 2011: How to find records based on different filters? RRS feed

  • Question

  • Goal:

    I want to make a workflow or plugin that finds me some records if they exist but with some filtering. Say i want to check before creating a record for entity A that another record doesnt exisst with same values. I know this can be down with dublicates check but not exactly. Some times the name is mispelled or mistyped and what happen is having the same client with two diffrent contact.

    1)I first want to check if the name is the same.

    - if it is the same also check the date of birth because sometimes we have relatives with same name or just coicedence.

    - if not check the date of birth again beacuse a misspelled or misstyped .

    2)date of birth checking.

    - if date of birth is not the same then go on to check the email address.

    - if same then most probably you have that client already in your system but to be sure check the email too.

    3)email address

    - if the same then check also the phone number

    - if not the same go check the phone number again.

     

    4) phone number

    - if not the same client does not exist

    - if the same then client exist.

     

    so it is a tree of searches with everything to make sure duplicate records aarent created. How can i do this? i know how to get a records with one search criteria and then for the other use a loop but then and also performance wise it will not be good. is there a way to use something like when i retrieve all the records with same name take those records and check email only on those records?something like a joint...

    Enviroment:

    CRM 2011 On-Premise ver:5.0.9688.583 ,Server OS: Windows Server 2008 R2 64bit, Client OS: Windows 7 64bit, email router not installed, SQL SErver 2008, different servers for crm and sql,Office 2007, not the final production system but a development sytem.

     

    Thank you.


    Please vote if I helped out :) thanks all in this forum for helping with any problem i had.
    Friday, May 13, 2011 8:56 AM

Answers

  • With CRM 2011 OnPremise plugins you can use the early bound classes to write fairly complex queries in a relatively straight-forward manner.  Something like:

     

    IEnumerable<Guid> contacts = 
     (
     from c in context.ContactSet
     where 
      (c.FullName == fullName && c.BirthDate == dob)
      ||
      (c.EmailAddress1 == email && c.BirthDate == dob)
      ||
      (c.EmailAddress1 == email && c.Telephone1 == phone)
     select c.Id
     );
    
    if (contacts.Count() > 0)
    {
     // dupe!!
    }
    

     


    --pogo (pat) pogo69.wordpress.com
    • Marked as answer by gokou84san Friday, May 13, 2011 10:52 AM
    Friday, May 13, 2011 10:32 AM

All replies

  • With CRM 2011 OnPremise plugins you can use the early bound classes to write fairly complex queries in a relatively straight-forward manner.  Something like:

     

    IEnumerable<Guid> contacts = 
     (
     from c in context.ContactSet
     where 
      (c.FullName == fullName && c.BirthDate == dob)
      ||
      (c.EmailAddress1 == email && c.BirthDate == dob)
      ||
      (c.EmailAddress1 == email && c.Telephone1 == phone)
     select c.Id
     );
    
    if (contacts.Count() > 0)
    {
     // dupe!!
    }
    

     


    --pogo (pat) pogo69.wordpress.com
    • Marked as answer by gokou84san Friday, May 13, 2011 10:52 AM
    Friday, May 13, 2011 10:32 AM
  • Thanks Pogo. I have to work on my query buildning now :)
    Please vote if I helped out :) thanks all in this forum for helping with any problem i had.
    Friday, May 13, 2011 10:53 AM