AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents
TypeScript ai-agentai-agent-toolsai-agentsai-agents-frameworkmcpmcp-servermcp-toolsmcpsn8n-alternativeno-code-automationworkflowworkflow-automationworkflows
import { Property, createAction } from '@activepieces/pieces-framework';
import { HttpMethod } from '@activepieces/pieces-common';
import { salesforceAuth } from '../..';
import { callSalesforceApi, salesforcesCommon } from '../common';
import { reportUtils, SalesforceReportResponse } from '../common/report';
import { runReportSyncOutputSchema } from '../output-schemas';
export const runReport = createAction({
auth: salesforceAuth,
name: 'run_report',
classification: 'READ',
displayName: 'Run Report',
description: 'Runs a report and returns its rows.',
audience: 'human',
aiMetadata: { description: 'Run an existing Salesforce analytics report by its report Id and get back flattened rows (detail and grouping columns) instead of raw factMap structures. Optionally pass dynamic filters to override the report\'s saved filters for this run. Use to read aggregated/reported data rather than to query raw records. Read-only and idempotent — it executes the report without changing it.', idempotent: true },
outputSchema: runReportSyncOutputSchema,
props: {
report_id: salesforcesCommon.report,
filters: Property.Json({
displayName: 'Filters',
description:
'JSON list of column, operator and value. Empty: the saved filters.',
required: false,
}),
},
async run(context) {
const { report_id, filters } = context.propsValue;
let body = undefined;
if (filters && Array.isArray(filters) && filters.length > 0) {
body = {
reportMetadata: {
reportFilters: filters,
},
};
}
const queryParam = '?includeDetails=true';
const response = await callSalesforceApi<SalesforceReportResponse>(
HttpMethod.POST,
context.auth,
`/services/data/v56.0/analytics/reports/${report_id}${queryParam}`,
body
);
const reportData = response.body;
return reportUtils.transformReportToRows(reportData);
},
});