Async API + React HTML Components
This page covers the changes added to the Buzzy Frame API, giving full control to the user when calling API endpoints. Usage of such an API is explored as React components.
What's this?
The iframe API gives users access to pre-existing sandbox API endpoints without the need for message handling. We've exposed a set of asynchronous functions that can be awaited, this ensures that HTML components can be more deterministic as a result is guaranteed. Buzzy handles the message handling, making your HTML code snippets simpler!
This feature is current opt-in and you must enable it through the HTML field settings under "Enable Async API".
Script Placement
Warning
You must place the <script> inside the <body> of your custom HTML code.
This is important as the Buzzy Frame API is loaded in the head and may not be available due to loading order.
Available Asynchronous Functions
Data Management
Insert a Row
Usage
Return
Linked Table Field Example
When inserting a row with linked table (cross app) fields using the async API, provide both the crossAppRowID and value object in the rowData:
Key Points:
crossAppRowID: The_idof the row in the linked tablevalue.label: The field name from the linked table to displayvalue.value: The actual display value from that field
See Also:
REST API insertmicroapprow - REST API equivalent
microappdata/row - Understanding linked table field structure
Update a Row
Usage
Return
Linked Table Field Update Example
When updating linked table (cross app) fields using the async API, provide the complete linked field structure:
Important Notes:
To update a linked table field, provide the new
crossAppRowIDand correspondingvalueTo clear a linked table field, set the field to
nullinrowDataThe
value.labelshould match a field name in the linked tableThe
value.valueshould be the display value from that field
See Also:
REST API updatemicroapprow - REST API equivalent
microappdata/row - Understanding linked table field structure
Remove a Row
Usage
Return
None.
Fetch Embedded Row Data
Usage
Return
Resource as JSON.
Fetch All Embedded Data
Usage
Return
Object with all data tables and sub tables resolves to N levels.
Fetch Data Table Rows 🆕
Usage
Return
Array of data table rows as JSON.
Filter Data View 🆕
filterMicroappView
Apply filters to a microapp view to show only specific data rows. This method allows you to create search and filtering functionality within code widgets.
Usage
Parameters
microAppID(string): ID of the data-table (microapp) to filterembeddingRowID(string, optional): ID of the embedding row (used for sub-table filtering)viewFilters(array): Array of filter objects using MongoDB query syntaxviewFilterIsMongoQuery(boolean): Whether to use MongoDB query language for complex filteringfilterContext(string): String identifier for the filter context to distinguish between different filters
Return
Example - Complete Contact Age Filter Implementation
Advanced Usage Patterns
When implementing filterMicroappView in production applications, follow these patterns demonstrated in the example above:
1. BuzzyFrameAPI Lifecycle Management
Always instantiate
BuzzyFrameAPIoutside React components to prevent re-initializationCall
buzzyFrameAPI.initialise()once during component mountSet up microapp listeners immediately after initialization
2. Reactive Data Updates
Use
addMicroappListener()to automatically refresh data when the underlying microapp changesTrack filter state with
useRefto ensure listeners can access current filter parametersImplement proper cleanup in
useEffectreturn functions if needed
3. Error Handling and User Experience
Wrap all async operations in try/catch blocks
Provide meaningful error messages to users
Implement loading states for better user feedback
Include debug logging for development and troubleshooting
4. State Management
Use React state for UI-related data (loading, error, results)
Use
useReffor values that need to persist across renders but don't trigger re-rendersSeparate filter application from data fetching for better code organization
5. Performance Considerations
Debounce filter inputs to avoid excessive API calls
Cache filter results when appropriate
Use
filterContextparameter to distinguish between different filter instances
This method applies the filters to the view outside the code widget, allowing users to create custom search interfaces that filter the main application data reactively.
Query Options (Pagination) and Filtering
When fetching embedded row data, you might to do pagination, filtering, and/or limit the number of results that you get. Buzzy uses MongoDB under the hood, as such, view filters follow the rules for MongoDB queries. This includes support for geo/spatial queries using sortValGeometry - see geo/spatial query examples for more details.
Query Options (Pagination and Data Limits)
Query options allow you to control the number of results you get back from the query, as well as allowing you to do pagination using the skip parameter. Common supported MongoDB aggregation parameters:
More info on Sorting:
The data fetched from the Microapp can be sorted. The order and field parameters are used in the searchFilter to specify which Microapp sort field and if it is ascending or descending. The sort fields are configured in the Microapp Results Tab. Sort field 1 corresponds to the field value 1 and so on. Where order is either 1 = ascending or -1 = descending.
Example fetching microapp rows using Sort Field 1.
View Filters (Filtering)
In cases where you might want to filter the results based on the value of a field, you can query based on the value of a field of the data table row. viewFilters is an array of view filters to be used, as such you may filter many views as they are scoped to the data table ID (resourceID).
Combining the Above Concepts, see the following example with filtering and pagination included:
In the example above, the query will fetch rows where the sortVal contains the word "Lasagna", in this case, the sortVal is referencing the data table row title (the recipe title). The query options them limit the rows to only 1 row, while skipping 0. If we were doing some pagination, when a user clicked a "Next Page" button, we could change the skip to 1 so it would get the next recipe that satisfies the filters.
MicroAppChild Management
createMicroappChild
Creates a new MicroAppChild entry.
Example usage for file upload:
getChildItemsByField
Retrieves all MicroAppChild entries for a specific parent app item and field.
Example usage for fetching images:
updateMicroappChild
Updates the content of a MicroAppChild entry.
Example usage for updating file URL:
removeMicroappChild
Deletes a MicroAppChild entry.
Navigation
navigate
Navigates to a different screen within the same app.
Example usage:
getScreenID
Helper method to get the screenID for navigation.
Organization & Team Management
createOrganization
Creates a new organization.
readOrganization
Reads an organization by ID.
updateOrganization
Updates an organization's information.
deleteOrganization
Deletes an organization.
createTeam
Creates a new team within an organization.
readTeam
Reads a team by ID.
updateTeam
Updates a team's information.
deleteTeam
Deletes a team.
createTeamMember
Adds a member to a team.
readTeamMember
Reads a team member by team ID and user ID.
updateTeamMember
Updates a team member's role.
deleteTeamMember
Removes a member from a team.
Listen for Updates
Usage
Register a listener function for a given microapp (aka data table).
Whenever data is added or updated that fits the query you have running on the given microapp, the supplied listener function will be executed. In the native app version, this function will also be run if the user initiates a refresh by dragging down on the screen.
Typically this would be used to re-run your query and set the results to a state variable, and thus trigger re-rendering of your fetched data whenever it is updated.
The listener will be passed on object with these properties:
microAppID - the id that passed into the listener
isUserRefresh - true if this is a user initiated refresh
timestamp - timestamp of the update that triggered the listener
Code Example
Preamble
The API works best within the context of a sandbox iframe (see the Code Widget documentation for security considerations). In our examples and testing, we utilise the React front-end library to construct HTML snippets. We've found that the behaviour of UI elements using React for HTML components allows for more granular control over rendering and state. As such, in the examples shown on this page, we will use React with functional components.
Buzzy HTML Field Settings
Due to the usage of React, we want to disable handlebars and opt-in to the new Async API. This is easily accomplished in the settings panel of the HTML field definition:

Our Example Data table Layout
As a reference for the code snippet, the fields and set up of the data tables referenced in the code example are provided below:
Fruit Reports (Data table)
Fruit Report (Text)
Date (Datetime)
Fruit Counters (Sub table)
Graphic-HTML (HTML Field)
Fruit Counters (Sub table)
Fruit Type (Select list)
Number (Count)
Date Counted (Datetime)
Code
Result
With some data table rows, the above example provides the following output in Buzzy:\

Advanced Examples
Example 1: Course Enrollment with File/Image Copying
This example demonstrates how to create a course enrollment system that:
Creates a copy of a course template for a user
Copies all associated questionnaires, questions, and options
Handles file and image copying between templates and user instances
Uses navigation to guide the user through the process
This example demonstrates several key features:
Using
getChildItemsByFieldto fetch file and image attachmentsUsing
createMicroappChildto copy attachments to new rowsUsing
navigateto guide users through the enrollment processHandling complex data relationships and maintaining referential integrity
Example 2: Course Unenrollment with Cleanup
This example shows how to properly remove a course and all its associated data, maintaining referential integrity:
This example demonstrates:
Proper cleanup of nested data structures
Using
navigateto show processing and completion statesMaintaining referential integrity during deletion
Error handling and user feedback
Limitations
The current iteration of the new API is still under development. There are a number of key issue yet to be resolved:
Last updated