Skip to main content

Notifications

Microsoft Dynamics CRM (Archived)

Working with Alternate keys in CRM

Posted on by 795

Hi,

I am having an alternate key with a combination of two fields.Its working fine.If i am getting unique combination each time, record is created else duplicate doesn't get create.

But, if one of the field is empty , then duplicates are getting created.So, how can i have a check that if that particular field is null, then the other field act as an alternate key..Is this possible?

Thanks

*This post is locked for comments

  • Suggested answer
    gdas Profile Picture
    gdas 50,085 on at
    RE: Working with Alternate keys in CRM

    Here is the link for exception handling

    msdn.microsoft.com/.../gg327884.aspx

  • CRM Beginner  Profile Picture
    CRM Beginner 795 on at
    RE: Working with Alternate keys in CRM

    Thanks for the replies..One more help required..

    If i am using Alternate Keys, based on that i am creating a record like-:

    id = service.Create(entity);

    once this record is created, next time if it finds same pair of attribute values , exception is thrown..How to catch that exception using C# code?

  • Suggested answer
    gdas Profile Picture
    gdas 50,085 on at
    RE: Working with Alternate keys in CRM

    Hi,

    When you define multiple keys in entity  , its basally works internally checking AND condition in background.Null value can not consider in the key to validate. The key will work or consider only when you set the  value to the field. So using key its not possible,

    You can implement  custom rule using plugin.

  • Suggested answer
    Sudheer Reddy Profile Picture
    Sudheer Reddy 115 on at
    RE: Working with Alternate keys in CRM

    Its not possible OOB. To make it work, instead of null always assign some default value to the field.

  • Suggested answer
    RaviKashyap Profile Picture
    RaviKashyap 55,410 on at
    RE: Working with Alternate keys in CRM

    Hi,

    I don't think it is possible with alternate keys. Is it possible for you to atlease have some default value in that field?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,240 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,149 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans