Fetch records for datatable
Function: Fetch records for datatable
Fetch records from the database for a datatable. This action allows you to retrieve data from your application's database and display it within a datatable UI element on your page. You can specify which data to fetch, apply filters, select specific attributes, and define the sorting order.
Input,
- UI element
- Description: The datatable UI element on your page that you want to populate with records.
- Type:
PART(specifically a datatable) - Required: Yes
- Data format
- Description: The type of data (e.g., "Products", "Customers", "Orders") you want to fetch records for.
- Type:
DATA_FORMAT - Required: Yes
- Filters
- Description: Define rules to narrow down the list of records. All rules in this section must be true for a record to be included (AND relationship).
- Type:
ARRAYofOBJECTs (each object is a filter rule)- Attribute: Select the field in your data format that you want to check.
- Operator: Choose how the attribute should be compared (e.g., "Equal", "Greater than", "Contains").
- Value: Provide the value to compare against the attribute. (This input is hidden if the operator is "Is null" or "Is not null").
- Filters (OR)
- Description: Define additional rules to narrow down the list of records. If any rule in this section is true, the record will be included (OR relationship). These filters are applied in combination with the "Filters" (AND) section.
- Type:
ARRAYofOBJECTs (each object is a filter rule)- Attribute: Select the field in your data format that you want to check.
- Operator: Choose how the attribute should be compared (e.g., "Equal", "Greater than", "Contains").
- Value: Provide the value to compare against the attribute. (This input is hidden if the operator is "Is null" or "Is not null").
- Attributes
- Description: Choose specific fields from your data format that you want to retrieve. If left empty, all fields will be fetched.
- Type:
ARRAYofOBJECTs (each object is an attribute selection)- Attribute: Select a specific field you want to include in the fetched data.
- Sort by
- Description: Define rules to arrange the fetched records in a specific order.
- Type:
ARRAYofOBJECTs (each object is a sorting rule)- Attribute: Select the field by which you want to sort the records.
- Order: Choose "Ascending" (A-Z, 0-9) or "Descending" (Z-A, 9-0).
- Clear datatable
- Description: If set to
True, the datatable will be emptied of its current records before new records are added. IfFalse, new records will be added to the existing ones. - Type:
BOOLEAN - Default:
False
- Description: If set to
- Hide the identifier column
- Description: If set to
True, the unique ID column for each record will not be displayed in the datatable. IfFalse, it will be visible. - Type:
BOOLEAN - Default:
True
- Description: If set to
Output,
This action updates the specified datatable UI element directly on your page. The datatable will be populated with the fetched records, reflecting any applied filters, attribute selections, and sorting.
Execution Flow,
Real-Life Examples,
Example 1: Display All Active Products
Imagine you have a datatable on your "Product Management" page and you want to show all products that are currently active.
- Inputs:
- UI element:
MyProductsDatatable(the datatable component on your page) - Data format:
Product - Filters:
- Rule 1:
- Attribute:
Status - Operator:
Equal - Value:
Active
- Attribute:
- Rule 1:
- Clear datatable:
True - Hide the identifier column:
True
- UI element:
- Result: The
MyProductsDatatableon your page will be cleared, and then populated with a list of all products whose status is "Active". The unique ID for each product will not be visible.
Example 2: Show Recent Orders from Specific Customers, Sorted by Date
You have a "Dashboard" page with a datatable to monitor recent orders. You want to see orders placed by "Premium" or "VIP" customers within the last 30 days, showing only the order ID, customer name, and order date, sorted by the most recent first.
- Inputs:
- UI element:
RecentOrdersTable - Data format:
Order - Filters:
- Rule 1:
- Attribute:
OrderDate - Operator:
Greater than or equal - Value:
[Current Date - 30 Days](a variable representing 30 days ago)
- Attribute:
- Rule 1:
- Filters (OR):
- Rule 1:
- Attribute:
CustomerType - Operator:
Equal - Value:
Premium
- Attribute:
- Rule 2:
- Attribute:
CustomerType - Operator:
Equal - Value:
VIP
- Attribute:
- Rule 1:
- Attributes:
- Attribute 1:
OrderID - Attribute 2:
CustomerName - Attribute 3:
OrderDate
- Attribute 1:
- Sort by:
- Rule 1:
- Attribute:
OrderDate - Order:
Descending
- Attribute:
- Rule 1:
- Clear datatable:
True - Hide the identifier column:
False
- UI element:
- Result: The
RecentOrdersTablewill display orders from either "Premium" or "VIP" customers that were placed in the last 30 days. Only the Order ID, Customer Name, and Order Date columns will be visible, and the list will be sorted from the newest order to the oldest. The unique ID for each order will be visible.
Example 3: Find Employees in a Specific Department with a Partial Name Match
On your "Employee Directory" page, you want to find employees in the "Marketing" department whose name contains "john" (case-insensitive).
- Inputs:
- UI element:
EmployeeListDatatable - Data format:
Employee - Filters:
- Rule 1:
- Attribute:
Department - Operator:
Equal - Value:
Marketing
- Attribute:
- Rule 2:
- Attribute:
FullName - Operator:
Contains \(ignore case\) - Value:
john
- Attribute:
- Rule 1:
- Clear datatable:
True - Hide the identifier column:
True
- UI element:
- Result: The
EmployeeListDatatablewill be updated to show only employees who work in the "Marketing" department and whose full name includes "john" (e.g., "John Doe", "Johnny Smith", "Mary Johnson"). The unique ID column will be hidden.