
Hello community,
In this blog, I’ll show you how to add a search bar with suggestions to your SAP Build Apps application.
Scenario Overview
Imagine you have an app where you need to search through a list of manufacturers containing over 40,000 entities. Efficiently navigating such a large dataset can be challenging. You want to search using a search bar while also being able to manually browse the list.
Step 1: Creating the Search Component and a Data Variable for the Manufacturers List
Start by creating a component that serves as your search bar, along with a button to open the full list of manufacturers. Here’s how to do it:
!IS_EMPTY(appVars.selected_manufacturer) && appVars.selected_manufacturer != repeated.current.manufacturerName
Note: Here, selected_manufacturer is stored as an app variable because it's needed outside of this page. However, if it's only required on this page, you can use a page variable instead.
Step 2: Displaying the Manufacturer List
When you click on the search bar icon, it should navigate to a page displaying your manufacturer list. This list is fetched using pagination. If you need help with pagination, refer to this blog on handling OData pagination in SAP AppGyver.
Step 3: Implementing Search Functionality
The search process should be triggered when the variable tied to your custom component changes. You can use the following approach when retrieving your record collection from the backend:
{"type":"and","conditions":[{"type":"containsIgnoreCase","property":["manufacturerName"],"value":appVars.selected_manufacturer }]}
2. Set Data Variable: Slicing the results. After applying the search filter, limit the results to the first eight records:
SLICE(outputs["Get record collection"].records, 0,8)
Alternative Approaches
Here are some alternative methods and tools that can be used for implementing a search bar with suggestions in SAP Build Apps:
OData Search Capability
Search Bar with Suggestions (Video Tutorial)
Combo Box Component
Conclusion
Depending on your specific requirements, you can choose from several approaches to implement a search bar with suggestions in SAP Build Apps. For smaller datasets, you can refer to the video tutorial included in this blog. Alternatively, you can use a pre-built component for simpler implementations or build a custom component to handle larger datasets.
Now, go ahead and build something amazing!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
11 | |
9 | |
9 | |
7 | |
4 | |
3 | |
3 | |
3 | |
2 | |
2 |