Monetize360
WorkflowsFunctionsSystem Functions

Pipeline Query

Execute a query, create a materialized view, and optionally write results to an Object with flexible field mappings

Pipeline Query

Execute a query and create a materialized view for use in subsequent workflow steps. Optionally write query results directly to an Object with flexible field mappings supporting constants, runtime values, and node field references.

Technical Name: PipelineQueryFunc

Properties

  • Execution Mode: SYNC
  • Type: NATIVE
  • Category: System Functions
  • Function ID: 1b4ff763-94ad-4726-8dbe-c95a65ad0c00

Input Schema

Required Parameters

ParameterTypeDescription
queryMasterobjectQuery configuration object for building the SQL query

Optional Parameters

ParameterTypeDescription
writeToMobjectobjectConfiguration to write query results to an Object

WriteToMobject Configuration

ParameterTypeDescription
mobjectIdstring (uuid)ID of the target Object to write data to
fieldMappingsarrayArray of field mappings between source query and target Object

Field Mapping Properties

ParameterTypeDescription
mobjectFieldstringName of the field in the target Object (required)
sourceTypestringType of source: "FIELD", "CONSTANT", "RUNTIME_CONSTANT", or "NODE_FIELD" (required)
sourceFieldstringName of the field from query results (required if sourceType is FIELD)
constantValuestringConstant value to use (required if sourceType is CONSTANT)
runtimeConstantKeystringRuntime constant key (required if sourceType is RUNTIME_CONSTANT)
nodeFieldIdstringNode field identifier in format "nodeId->fieldName" (required if sourceType is NODE_FIELD)

[Image placeholder: PipelineQuery function configuration panel]

Source Types

FIELD

Map a field directly from the query results:

{
  "mobjectField": "customerName",
  "sourceType": "FIELD",
  "sourceField": "name"
}

CONSTANT

Use a constant value:

{
  "mobjectField": "status",
  "sourceType": "CONSTANT",
  "constantValue": "Active"
}

RUNTIME_CONSTANT

Use a runtime constant value:

Available Runtime Constants:

  • CURRENT_USER - Current user's username
  • CURRENT_USER_ID - Current user's ID
  • CURRENT_ROLE - Current user's role names (comma-separated)
  • CURRENT_ROLE_ID - Current user's role ID
  • CURRENT_TIMESTAMP - Current local timestamp
  • CURRENT_UTC_TIMESTAMP - Current UTC timestamp
  • TODAY - Current date
  • EXECUTION_ID - Current workflow execution ID
  • REQUEST_ID - Current request ID
{
  "mobjectField": "createdBy",
  "sourceType": "RUNTIME_CONSTANT",
  "runtimeConstantKey": "CURRENT_USER_ID"
}

NODE_FIELD

Reference a field from a previous workflow node:

{
  "mobjectField": "orderId",
  "sourceType": "NODE_FIELD",
  "nodeFieldId": "node-123->orderId"
}

Input Example

Query Only (Create Materialized View)

{
  "queryMaster": {
    "selectFields": [
      {
        "fieldName": "name",
        "fieldAlias": "customerName"
      },
      {
        "fieldName": "email",
        "fieldAlias": "email"
      }
    ],
    "fromClause": {
      "mobjectId": "customer-mobject-uuid"
    }
  }
}

Query with Write to Object

{
  "queryMaster": {
    "selectFields": [
      {"fieldName": "name", "fieldAlias": "customerName"},
      {"fieldName": "email", "fieldAlias": "email"}
    ],
    "fromClause": {
      "mobjectId": "customer-mobject-uuid"
    }
  },
  "writeToMobject": {
    "mobjectId": "report-mobject-uuid",
    "fieldMappings": [
      {
        "mobjectField": "customerName",
        "sourceType": "FIELD",
        "sourceField": "customerName"
      },
      {
        "mobjectField": "email",
        "sourceType": "FIELD",
        "sourceField": "email"
      },
      {
        "mobjectField": "status",
        "sourceType": "CONSTANT",
        "constantValue": "Processed"
      },
      {
        "mobjectField": "createdBy",
        "sourceType": "RUNTIME_CONSTANT",
        "runtimeConstantKey": "CURRENT_USER_ID"
      }
    ]
  }
}

Output Schema

FieldTypeDescription
viewNamestringGenerated materialized view name (can be used in subsequent queries)
sqlstringThe SQL query that was executed
rowsInsertedintegerNumber of rows inserted into Object (only if writeToMobject was configured)
writeSuccessbooleanWhether the write operation was successful (only if writeToMobject was configured)

Output Example

Query Only

{
  "viewName": "a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6",
  "sql": "SELECT name AS customerName, email FROM customer_table WHERE status = 'Active'"
}

With Write to Object

{
  "viewName": "a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6",
  "sql": "SELECT name AS customerName, email FROM customer_table WHERE status = 'Active'",
  "rowsInserted": 150,
  "writeSuccess": true
}

[Image placeholder: Pipeline query output visualization]

How It Works

  1. Query Execution: Executes the query defined in queryMaster
  2. Materialized View Creation: Creates a materialized view with a unique name
  3. Optional Write Operation: If writeToMobject is configured:
    • Maps query fields to Object fields using field mappings
    • Supports constants, runtime values, and node field references
    • Creates data ownership records automatically
    • Inserts records into the target Object

Use Cases

Create Reusable Query View

Create a materialized view for use in multiple workflow steps:

{
  "queryMaster": {
    "selectFields": [
      {"fieldName": "orderNumber", "fieldAlias": "Order"},
      {"fieldName": "totalAmount", "fieldAlias": "Amount"}
    ],
    "fromClause": {
      "mobjectId": "order-mobject-uuid"
    },
    "where": [
      {
        "field": "status",
        "operator": "equals",
        "value": "Completed"
      }
    ]
  }
}

Transform and Load Data

Query data, transform it, and write to another Object:

Start → PipelineQuery(Query + Write) → ProcessResults → End

Use Runtime Values

Populate audit fields automatically:

{
  "queryMaster": {...},
  "writeToMobject": {
    "mobjectId": "audit-mobject-uuid",
    "fieldMappings": [
      {
        "mobjectField": "createdBy",
        "sourceType": "RUNTIME_CONSTANT",
        "runtimeConstantKey": "CURRENT_USER_ID"
      },
      {
        "mobjectField": "createdAt",
        "sourceType": "RUNTIME_CONSTANT",
        "runtimeConstantKey": "CURRENT_TIMESTAMP"
      }
    ]
  }
}

[Image placeholder: Workflow examples]

Materialized View Usage

The generated viewName can be used in subsequent queries:

SELECT * FROM "a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6"

Data Ownership

When writing to Object, the function automatically:

  • Creates data ownership records for the current organization
  • Sets system fields (created_at, created_by, updated_at, updated_by, deleted)
  • Ensures proper data isolation across organizations