Transcript
In this Quick Tip, we're going to learn about primary fields.
When you create a data type, you create custom fields and when you view these fields in App Data, you see them displayed as columns like so.
Here we have our user type that has a custom field for what Company this user belongs to. If we go to edit that user manually and add a Company, when we type it in, nothing happens. Our search for which Company this user belongs to, doesn't show any result. This is because our primary field for our Company data type is set to unique ID and we're searching for it by Name.
To change this, we click Primary fields. Here we have a list of all of our data types and their default primary fields.
So since we want to define a specific Company by their Name, we would set the primary field for the Company to be its custom field Name. It's up to you to decide which field is best to describe a Thing in the table, and for it to show up as you intend when you're editing App Data.
For example, the built-in user primary field is email since it's the easiest way to find users since each user's email address is unique. If you set the user's primary field to Name, you can end up with tons of duplicates if you user's all have the same name.
The unique ID is always a safe choice as it's unique to the thing but isn't something you can easily remember.
So now when we edit our user and we want to select which Company they belong to, we can search by the company's Name.
That's it for this Quick Tip! For more, be sure to check out bubble.io/academy.