This example shows how to use a Price Builder QueryAPI query as input to model.loadTable so that you can populate a Data Model Table (DMT) directly from a QueryAPI result.
This removes the need to manually iterate over query results and push rows into a DMT yourself. Instead, model.loadTable recognizes the Price Builder QueryAPI query, executes it, and loads the result into the DMT using the dataloader.
Use this pattern when:
-
You need to copy or transform data from Price Builder tables (Products, Customers, Company Parameters, etc.) into a DMT.
-
You want to join Price Builder data with Analytics data inside a data model, for example to power Agents or downstream calculations.
-
You previously implemented a manual loop over query results to fill a DMT and want a simpler and more maintainable approach.
Typical use cases include:
-
Preparing a DMT that combines transactional data from Analytics with master data from Price Builder.
-
Filtering and reshaping Price Builder data via QueryAPI before persisting it into a DMT.
Example: Loading a DMT from a QueryAPI Query
1. Build the QueryAPI query in Price Builder
In a Price Builder logic step, use QueryAPI to define which data you want to copy into the DMT:
// Example: Get all active products with their list price from a Price Builder table
def query = qapi
.from("Products") // Source table
.select("sku", "listPrice") // Columns to include in the result
.where(qapi.eq("isActive", true)) // Filter only active products
In this example:
-
"Products"is a Price Builder table configured in your project. -
sku,listPrice, andisActiveare columns (or attributes) exposed by that table. -
The query result will contain only active products with the selected fields.
2. Load the query result into a DMT using model.loadTable
Now pass the query object to model.loadTable together with the target DMT name:
// Load the query result into a Data Model Table
model.loadTable(
"ProductsFromPB", // Target DMT name (must exist in your data model)
query // PB QueryAPI query defined above
)
What happens here:
-
model.loadTabledetects that the second argument is a QueryAPI query. -
It runs the query, and the result becomes the input dataset.
-
The result is then loaded into the DMT named
"ProductsFromPB"via the dataloader.
After this call, the DMT ProductsFromPB contains one row per product that matched the query, with columns populated according to the mapping between the query result and the DMT schema.