Monetize360
WorkflowsFunctionsSystem Functions

Run Report

Execute reports based on MReportMaster configuration and return report data. Supports existing reports by ID or ad-hoc reports with full configuration

Run Report

Execute reports based on MReportMaster configuration and return report data. The function supports executing existing saved reports by ID or creating ad-hoc reports with full configuration. It supports multiple input patterns for flexibility.

Technical Name: RunReportFunc

Properties

  • Execution Mode: SYNC
  • Type: NATIVE
  • Category: System Functions
  • Function ID: a7c9f3b2-4e5d-4a1f-9b8c-2d3e4f5a6b7c

Input Schema

The function supports three input patterns:

Pattern 1: Nested with reportConfig (Ad-hoc Reports)

Use this pattern for ad-hoc reports with full configuration:

ParameterTypeDescription
reportConfigobjectComplete MReportMaster configuration object
formatResponsebooleanWhether to format the response (default: false)

Pattern 2: Nested with reportMaster (Ad-hoc Reports)

Alternative nested pattern:

ParameterTypeDescription
reportMasterobjectComplete MReportMaster configuration object
formatResponsebooleanWhether to format the response (default: false)

Pattern 3: Flat Structure (Existing Reports)

Use this pattern for existing reports by ID or flat configuration:

ParameterTypeDescription
reportIdstring (UUID)UUID of existing report to execute
reportNamestringName of the report
flowIdstring (UUID)UUID of the flow to execute (optional)
dashboardIdstring (UUID)UUID of the dashboard (optional)
descriptionstringReport description
reportConfigobjectReport configuration (QueryMaster, filters, etc.)
additionalFiltersobjectAdditional filters to apply
drilldownFiltersobjectDrilldown filters to apply
globalFiltersobjectGlobal filters to apply
drillDownConfigobjectDrill down configuration
formatResponsebooleanWhether to format the response (default: false)

[Image placeholder: RunReport function configuration panel]

Input Examples

Execute Existing Report by ID

{
  "reportId": "123e4567-e89b-12d3-a456-426614174000",
  "formatResponse": false
}

Ad-hoc Report with Nested Config

{
  "reportConfig": {
    "reportName": "Sales Report",
    "reportConfig": {
      "query": {
        "selectFields": [
          {
            "fieldName": "amount",
            "fieldAlias": "Total Sales"
          },
          {
            "fieldName": "date",
            "fieldAlias": "Date"
          }
        ],
        "fromClause": {
          "mobjectId": "sales-mobject-uuid"
        },
        "criteriaTree": {
          "lhs": {
            "fieldName": "date"
          },
          "operator": "greaterThanOrEquals",
          "rhs": {
            "value": "2024-01-01"
          }
        }
      }
    },
    "additionalFilters": {},
    "globalFilters": {}
  },
  "formatResponse": true
}

Flat Structure with Filters

{
  "reportName": "Customer Analysis",
  "reportConfig": {
    "query": {
      "selectFields": [
        {
          "fieldName": "customer_name",
          "fieldAlias": "Customer"
        },
        {
          "fieldName": "total_orders",
          "fieldAlias": "Orders"
        }
      ],
      "fromClause": {
        "mobjectId": "customer-mobject-uuid"
      }
    }
  },
  "additionalFilters": {
    "status": "Active"
  },
  "formatResponse": false
}

Output Schema

FieldTypeDescription
successbooleanIndicates if the report execution was successful
dataobjectReport data result (structure depends on report type and formatResponse)
errorstringError message if execution fails

Output Example

Success Response

{
  "success": true,
  "data": {
    "columns": [
      {
        "fieldAlias": "Total Sales",
        "fieldName": "amount"
      },
      {
        "fieldAlias": "Date",
        "fieldName": "date"
      }
    ],
    "data": [
      {
        "Total Sales": 5000,
        "Date": "2024-01-15"
      },
      {
        "Total Sales": 7500,
        "Date": "2024-01-16"
      }
    ],
    "totalRecords": 2
  }
}

Error Response

{
  "success": false,
  "error": "Error executing report: Report configuration is required"
}

[Image placeholder: RunReport output visualization]

How It Works

The function performs the following steps:

  1. Parse Input: Detects the input pattern (nested reportConfig, nested reportMaster, or flat structure)
  2. Load Report Configuration:
    • If reportId is provided, fetches the saved report configuration
    • Otherwise, uses the provided configuration
  3. Apply Filters: Applies additional filters, drilldown filters, and global filters if provided
  4. Execute Report: Runs the report query using MReportService.runReport()
  5. Format Response: Optionally formats the response based on formatResponse flag
  6. Return Result: Returns report data with success status

Use Cases

Execute Saved Report

Run a pre-configured report by ID:

{
  "reportId": "saved-report-uuid"
}

Dynamic Report with Filters

Create a dynamic report with runtime filters:

{
  "reportConfig": {
    "reportName": "Dynamic Sales Report",
    "reportConfig": {
      "query": {
        "selectFields": [
          {"fieldName": "amount", "fieldAlias": "Sales"},
          {"fieldName": "region", "fieldAlias": "Region"}
        ],
        "fromClause": {
          "mobjectId": "sales-mobject-uuid"
        }
      }
    },
    "additionalFilters": {
      "region": "${workflow.region}",
      "date_range": "${workflow.dateRange}"
    }
  }
}

Workflow Report Execution

Execute reports within workflows:

Start → FetchMData → RunReport → ProcessResults → End

[Image placeholder: Workflow example]

Formatted Report Output

Get formatted report data:

{
  "reportId": "report-uuid",
  "formatResponse": true
}

Notes

  • Report ID Priority: If reportId is provided, the function loads the saved report configuration and ignores other configuration fields
  • Ad-hoc Reports: For ad-hoc reports, provide complete reportConfig with query structure
  • Filter Application: Filters are applied in order: global filters → additional filters → drilldown filters
  • Format Response: When formatResponse is true, the response includes formatted data suitable for display
  • Query Structure: The reportConfig.query follows QueryMaster structure with selectFields, criteriaTree, joinInfos, etc.
  • Materialized Views: Reports may use materialized views for performance optimization
  • Fetch MData - Retrieve MData records with filtering and pagination
  • Export - Export query results to CSV format
  • Pipeline Query - Execute queries with data transformation and materialized views