Skip to content

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

1.3 KB
Raw Blame
import { Property, createAction } from '@activepieces/pieces-framework';
import { salesforcesCommon } from '../common';
import { HttpMethod } from '@activepieces/pieces-common';
import { querySalesforceApi } from '../common';
import { salesforceAuth } from '../..';
import { runQueryOutputSchema } from '../output-schemas';

export const runQuery = createAction({
  auth: salesforceAuth,
  name: 'run_query',
  classification: 'SEARCH',
  displayName: 'Run Query',
  description: 'Runs a SOQL query in Salesforce.',
  audience: 'human',
  aiMetadata: { description: 'Run an arbitrary SOQL query string and return the matching records (read-only). Use this for any read needing multiple conditions, field selection, relationships, ordering, or aggregation that the simpler Find Record lookup cannot express; the caller must supply valid SOQL.', idempotent: true },
  outputSchema: runQueryOutputSchema,
  props: {
    query: Property.ShortText({
      displayName: 'Query',
      description: 'A SOQL query. Returns up to 2,000 records.',
      placeholder: 'SELECT Id, Name FROM Account LIMIT 10',
      required: true,
    }),
  },
  async run(context) {
    const { query } = context.propsValue;
    const response = await await querySalesforceApi<{
      records: { CreatedDate: string }[];
    }>(HttpMethod.GET, context.auth, query);
    return response;
  },
});