locked
Duplication Check RRS feed

  • Question

  • Hi everyone,

    I am a newbie in the CRM Dynamics 4, so I would like to seek your help. I have got a mapping table, and I want to check for duplication of a combination of two items on the "onsave event" of the mapping table. What is the code I should insert in the onsave event. Or maybe how to loop on already existing records?

    I am so thankful for your help
    Tuesday, November 4, 2008 11:33 AM

Answers

  • Hi,

     

    You need to ceate duplicate detection rules in data management section of CRM 4. then you need to write following code where you are updating your entity. This code specifies whether an entity instance will be created or updated if a duplicate is found.

     

    // Create operation – do not create, if a duplicate exists.
    CreateRequest reqcreate = new CreateRequest();
    reqcreate.OptionalParameters = new OptionalParameter[] { new CreateDuplicatesOptionalParameter(false) };

    // Update operation – do not update, if a duplicate exists.
    UpdateRequest requpdate = new UpdateRequest();
    requpdate.OptionalParameters = new OptionalParameter[] { new CreateDuplicatesOptionalParameter(false) };

    Tuesday, November 4, 2008 8:30 PM
    Moderator

All replies

  • Hi,

     

    You need to ceate duplicate detection rules in data management section of CRM 4. then you need to write following code where you are updating your entity. This code specifies whether an entity instance will be created or updated if a duplicate is found.

     

    // Create operation – do not create, if a duplicate exists.
    CreateRequest reqcreate = new CreateRequest();
    reqcreate.OptionalParameters = new OptionalParameter[] { new CreateDuplicatesOptionalParameter(false) };

    // Update operation – do not update, if a duplicate exists.
    UpdateRequest requpdate = new UpdateRequest();
    requpdate.OptionalParameters = new OptionalParameter[] { new CreateDuplicatesOptionalParameter(false) };

    Tuesday, November 4, 2008 8:30 PM
    Moderator
  • Hi Ayaz,

    Can you tell me where should i write this code- i mean whether in plugin???
    Thanks, Aarch
    Thursday, April 30, 2009 5:30 AM