Context Helper Documentation

The context object provides a powerful interface for accessing data and performing actions within the Report Static Query Builder. It's available globally as window.context and contains several key components.

Structure Overview

{
  params: {},       // Query parameters
  table: {},        // Available tables with data
  flow: Function,  // Load or open a flow
  form: Function,  // Open a form
  query: {}         // Query builder object
}

Components

params

The params object contains all query parameters available to the current report.

// Example
context.params.userId = "12345";
context.params.startDate = "2023-01-01";

table

The table object contains all available tables, where each table is a list of objects.

// Example
const firstUser = context.table.users[0];
const totalSales = context.table.sales.reduce((sum, sale) => sum + sale.amount, 0);

flow()

The flow() function allows you to load or open another flow from the current report.

Parameters:

executionType options:

  • openFlow: Opens the chosen flow in the dashboard

  • loadFlow: Loads the chosen flow in the background

form()

The form() function allows you to open a form from the current report.

Parameters:

query

The query property provides access to the query builder object. This powerful feature allows you to construct and execute queries programmatically.

Note: For detailed documentation on the query builder functionality, please refer to the Query Builder documentation in the other tab.

Practical Examples

Navigating between flows based on a condition:

Opening a form with data from the current context:

Loading a flow in the background and then reloading the current page:

Best Practices

  1. Parameter Management: When passing parameters to flows or forms, only include the parameters that need to change from the current context.

  2. Error Handling: Always ensure that the required IDs (flowId, formId) are valid before calling the respective functions.

  3. User Experience: Consider using reloadCurrent: true with caution as it will refresh the user's current view.

  4. Performance: When working with large tables, consider processing the data before navigating to another flow to minimize the data transfer.

Last updated