Skip to main content

Notifications

Community site session details

Community site session details

Session Id : euNHGHY10p41YKxSDU5c6H
Power Apps - Microsoft Dataverse
Unanswered

Alternate Key w/ Null values

Like (0) ShareShare
ReportReport
Posted on 14 Feb 2023 18:27:02 by 20

Hi,

 

For a model-driven app, I have an alternate key on a Dataverse entity comprised of 3 lookup columns, one of which is left null a majority of time. I still need to enforce uniqueness, which I've come to understand isn't supported for alternate keys.

 

My question is- has anyone out there found a workaround?

 

My only idea so far has been to default create a "Null" placeholder value in the problematic field.  This is not ideal for my current environment but will use as a last resort.

Categories:
  • Guido Preite Profile Picture
    1,488 Super User 2024 Season 1 on 31 May 2023 at 15:34:40
    Re: Alternate Key w/ Null values

    don't make things complicated. As you already imagined, just create a lookup value called "NULL" and set the lookup to be required. (you can also set it as default value with some javascript so users don't need to select it manually if often the value should be this null)

    EDIT: sorry, didn't notice the thread was old

  • Community Power Platform Member Profile Picture
    on 31 May 2023 at 12:59:11
    Re: Alternate Key w/ Null values

    An alternative approach is to create a string column on the table which contains a concatenation of all the other keys, including the nullable key, adding this to the keys, and making sure it is alway populated.

    So you could have end with a concatenated "key" of "00000000-0000-0000-0000-00000000000011111111-1111-1111-1111-11111111111122222222-2222-2222-2222-222222222222" when the nullable column isn't null, and a key of 33333333-3333-3333-3333-33333333333344444444-4444-4444-444444444444 when it is null.

    Hope this makes sense.

  • AhmedSalih Profile Picture
    6,678 Super User 2025 Season 1 on 15 Feb 2023 at 20:48:52
    Re: Alternate Key w/ Null values

    @KyleRichardson1, I see, the null value is not a value that can be tested against the Alternate Key. In this case your last resort is the only solution. 

  • KyleRichardson1 Profile Picture
    20 on 15 Feb 2023 at 20:14:29
    Re: Alternate Key w/ Null values

    @AhmedSalih Thank you for the response.

     

    Unfortunately, if there's a null value in any of the alternate key fields, it will not enforce uniqueness.

     

    For instance, if columns A, B, and C below are my key fields, it will allow the duplicate entry with null values in C, even though it should be recognized as a duplicate with the exact combination.

     

     Column AColumn BColumn C
    Record 1Lookup Value 123Lookup Value 456null
    Record 2Lookup Value 123Lookup Value 456null
  • AhmedSalih Profile Picture
    6,678 Super User 2025 Season 1 on 15 Feb 2023 at 19:52:43
    Re: Alternate Key w/ Null values

    Hello, @KyleRichardson1, Alternate keys must be unique. If you have your Alternate Key from three Columns: A, B & C, you can’t have two exact combinations.

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

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Congratulations to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Power Apps - Microsoft Dataverse

#1
stampcoin Profile Picture

stampcoin 17

#2
ankit_singhal Profile Picture

ankit_singhal 11 Super User 2025 Season 1

#3
mmbr1606 Profile Picture

mmbr1606 9 Super User 2025 Season 1

Overall leaderboard

Featured topics