Search

Implement global searching.

End-users can now search for specific entities within your ReST API, so now we want to enable the toolbar Search box to allow them to find any entity with a single search expression.

Typing in text and pressing <Enter> should respond with a drop down list of matching entities and their respective form icon.

For example this search is finding both footballers and nationalities:

Create a Search Data Source Request

Open App Studio, then open the Data Sources configurator.

Create a new Search folder beneath your data source folder, then use the add button menu to create a new request:

When the modal popup appears, enter the name of the new request e.g. "Search Function" and Save it.

Copy the ReST API global search function URL and paste this into the URL:

https://football-891b.restdb.io/views/Search?text=

Custom Variable

The hard-coded custom variable to use as the text of your URL parameter is called Search-Text. This is populated when the end-user types into the app toolbar search text box, so can be sent to your ReST API end-point.

Use the Insert Variable button to insert this into your URL:

The URL should now be:

https://football-891b.restdb.io/views/Search?text=<#Search-Text#>

The Authorisation should always default to "Inherit from parent".

Send Request

To test this search, use this button to send the request and get the list of fields and data. We can see on the Results tab that the JSON data returned shows the cross-entity search results from the ReST API:

Open App Studio, then open the App Toolbar configurator. Select the Search ... item in the Toolbar Elements panel:

Click this button to select the above data source request from the modal popup. The assigned data source request should now look like this:

Apply & Close

Apply & Close your changes to persist this configuration.

Test

You can now start typing a range of search expressions into the app toolbar search.

Test that data is returned as expected, and that selecting drop down items loads the correct form and record.

Last updated