web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / What is Key in CDS?
Power Apps
Unanswered

What is Key in CDS?

(0) ShareShare
ReportReport
Posted on by 515

Serious, what is Key in CDS? please share an example not an article

I have the same question (0)
  • CWesener Profile Picture
    Microsoft Employee on at

     

    Hi @Yahya - by default CDS entities have a GUID as their only unique field - but in another system you may use something like a Customer ID, or Order Number to uniquely identify a particular record. Defining a key allows you to make sure your field is also unique, and CDS won't allow duplicates of data to be entered within it. This can be especially helpful if you're integrating your data with an external system that uses that ID or number to identify a record (and not the CDS GUID). It also improves the search and filtering on the particular field, as we have indexes in place.

     

    Keys can be based on a single field (Order ID) or a combination of fields (example : Financial year and Order ID). If you set a key on a field and try to enter duplicate data, the record will fail to save.

     

    Does this help?

  • Yahya Manasrah Profile Picture
    515 on at

    Hi @CWesener, Thanks for the response. This reminds me with the property "Unique" in Access Web Apps database.

     

    2 things I would like to mention: -

     

    1. Creating a key via the PowerApps studio (online) will not prevent duplicating a record. This occurred in my tenant at least and I am willing to organize an online session so your team checks by themselves.

     

    I trued the Solution explorer, checked my index which I created from PowerApps studio to find that there is one more step to be done on the key, to activate/resume. it failed anyhow because of existing duplicates I think.

     

    I deleted, recreated, activated and it has worked perfectly then.

     

    There is therefore somethng missing in creating a key from the PowerApps studio that need to be fixed.

     

    2. Not all fields can be set as a Key for instance a Look up field. Now think of this scenario, I have 2 custom entities on the top of my database model, one is COUNTRY and the other is CITY. While I have entered all countries we work with, like 80 or so, cities are to be added by the users. I could create a key in CITY that is the City Name but for this is not correct in real life, as for instance, I have 2 cities called Tripoli, one is in Libya and the other is in Lebanon. So the right thing is to create a key from the concatenation of City Name and Country in the CITY entity, something not available because also calculated fields are not possible available to key feature.

     

    The same goes for a CUSTOMER and PROJECT REFERENCE, so none of my customers would have 2 different projects under the same PROJECT REFERENCE.

     

    what would be your thoughts handling this?

     

     

  • CWesener Profile Picture
    Microsoft Employee on at

     

    Hi @Yahya,

     

    Regarding the first issue - can take a few minutes for the key to be created, so if you immediately go and enter data, it wont be unique, and then the key will fail. We are looking at improving this experience in the portal.

     

    For the second item, this would be a new feature for us to support more data types in keys - can you please raise an idea on the ideas forum?

     

    Thanks,

    Clay.

  • majuarezg Profile Picture
    28 on at

    Regarding the unique key issue. It didn't work for me. I've been waiting for more than 30 minutes and I'm still able to add duplicated récords, so, maybe there is a kind of bug or something, or is it possible that I need to wait for a longer period? 

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Apps

#1
Haque Profile Picture

Haque 103

#2
WarrenBelz Profile Picture

WarrenBelz 82 Most Valuable Professional

#3
wolenberg_ Profile Picture

wolenberg_ 67 Super User 2026 Season 1

Last 30 days Overall leaderboard