Data pages can have multiple data sources, and you can set rules that determine which data source to use in a given situation so the application gets the right data every time.
At a high level, when the application invokes the data page, it can send values for one or more data page parameters. The data page can use the parameter values to select which of its data sources to use to respond to the current call, and which data from that data source to return.
Calling data pages with parameter values simplifies design and development and promotes code reuse, since a single data page can serve as a hub, quickly assembling and delivering the right set of data for a wide range of calls. Using parameters eliminates the labor and maintenance cost of creating and maintaining hard-coded calls for data.
To make use of multiple data sources, you need to do the following on the data page:
Specify more than one data source
On the Definition tab of a data page, you can specify one or many data sources.
If you specify multiple sources, a field appears where you identify the When condition (see below) that evaluates whether the current reference to the data page requires using the source identified in each row. The condition for the final data source is set as "Otherwise": that data source is used if all the preceding When conditions evaluate to false.
Click "Add New Source" to define an additional data source.
If there is more than one source listed, you can delete all but one. Click the "X" at the right of the information about the source you want to delete, to remove it.
You can drag data sources higher or lower in the list to set the order in which the system checks whether they should be used.
See How to create a data page (declare page) and the help documentation for details about what information to provide in each field.
When the system references a data page, it can pass one or more parameters that the data page can use to select exactly the data the system requires. Set those parameters on the Parameters tab.
See Use parameters when referencing a data page to get the right data.
Create a When condition
The data page uses the parameter values the referencing page submits, and a When condition, to determine what data to send back. In the example below, the When condition checks whether the value of the submitted parameter searchProvider is "Northwind".
If it is, the data page provides (and appropriately transforms so the application can use it) data drawn from the Northwind data source.
With these steps, the data page is prepared to respond to references sent with parameter values by returning data designed for the needs of each reference.
The data page can create a separate instance of itself on the clipboard for each time it is referenced with unique parameter values, or restrict the number of data page instances to one, so each new references overwrites the data page instance on the clipboard.