When you show the contents of a table in your app, you do not need to show every row, every column, and every action. Instead, you can "slice" the data, choosing a subset of the columns, actions, and rows.
What is a Slice?
A slice is a subset of the rows, columns, and actions of a table. A slice definition has five components:
- The table it's based on (required)
- Does the slice permit adds, deletes, and updates? (required)
- The subset of rows it retains from the table (optional)
- The subset of columns it retains from the table (optional)
- The subset of actions it retains from the table (optional)
It's important to note that a slice does not need to subset rows, columns, and actions. In fact, it's common to subset just the rows or just the columns/actions as appropriate.
Slices are most useful when you want to create a UX view of part of a table. For instance, if you have a table that's a list of people, you might have columns for their first name, last name, birthday, address, and phone number. However, if you only want to see their first name and phone number in a view, you can create a slice that filters out all the columns in the person table except for first name and phone number.
Remember, once you define the slice, you still need to use this slice in a UX view.
In the Editor
Below, we have the Slices tab in the editor. It's located in the Data section. You can add as many slices as you need with the "Add New Slice" button.
You'll then see these options for creating your new slice.
In order to preview what rows and/or columns of data your slice contains, select the "View Data" button. You can also name your slice something descriptive and choose from which table you are selecting data for the slice.
Here is an example of a completed slice in the National Parks app that uses an expression.
For more info, check out this demo on slices:
If you'd like to learn more about slices and filtering your data in depth, watch this webinar:
Using Multiple Slices
Richer apps can use more than one table slice.
In the Data > Slices tab, click on "New Slice” to add another data slice. It automatically gets added to your app when you save your changes.
Another use for slices is to define a logical subset of a table that can then be used in other expressions (e.g. in a Valid_If column constraint or in a workflow rule). For this usage scenario, slices usually use row filters but do not subset the columns or actions.