- 22 Aug 2022
- 2 Minutes to read
- Updated on 22 Aug 2022
- 2 Minutes to read
Data components are one of our most powerful features yet. They allow you to build highly reusable components with data-related logic built in, eliminating the need for app-level data variables. You can use data components together with different data resources and in different apps, and even download/publish them to the marketplace to make them available for other people to use. Public data components can be found using
#data-adapter tag in the view components section of the marketplace.
Some examples of data components include:
- A form component that creates records to a data table
- A selectable list component that syncs the selection information to a data table
- A widget type component for listing from and creating records to a data table (used in this article as an example)
How does a data component work?
What sets data components apart from regular components are data adapters that act as an abstraction layer between the component's internal logic and a data resource in the app. Installed component's adapter can be connected to any data resource with compatible fields and operations; for example, a configured REST API or the on-device storage of a mobile phone configured by you.
When connected to a data adapter, the data resource can then be used with private data variables or data flow functions inside the component. Data flow functions let you work with data inside the component similarly than you would on the page logic canvas: you can create new records, list or get existing records, update and delete them. Similarly to data variables in the page context, private data variables are used in the component context to hold single or list type values that are compatible with the schema of the connected data resource.
Mapping the data component
Upon installing a data component, you'll notice a property that can be mapped to a data resource. Mapping is a binding type that lets you assign one list of objects to another. It is used in the Data adapter configurator to connect data resource fields (i.e internal storage) to data adapter fields.
To map your data resource to a data component, find the property on the 'Properties' tab and press "Configure" under the adapter name. From there, simply drag-and-drop the available fields from the data resource to match the adapter schema on the right. You can alternatively use a formula, by clicking the formula binding button to the right of the field.
The data component is now ready to be used with your data resource.
Data components with BTP Destinations
Using data components together with BTP Destinations requires additional steps, refer to this guide for more information.