Add "Call Salesforce API" action

Created on 9 June 2025, 3 days ago

Problem/Motivation

Currently, users can only execute SOQL queries through the module. There's no way to make direct API calls like objectRead, objectCreate, or custom Apex endpoints.

This limits workflows that need to:
- Read a single record by ID
- Call custom Apex REST endpoints
- Get object metadata
- Access other Salesforce API operations

Steps to reproduce

1. Create an ECA model
2. Look for actions to call Salesforce API directly
3. Only SOQL query action is available

Proposed resolution

Add a new ECA action that provides direct access to Salesforce RestClient methods.

Remaining tasks

- [ ] Create action plugin
- [ ] Add configuration form with operation selection
- [ ] Implement token replacement in parameters
- [ ] Add error handling
- [ ] Test with various API operations

User interface changes

New action "Call Salesforce API" will appear in ECA with configuration for operation type and parameters.

API changes

None.

Data model changes

None.

✨ Feature request
Status

Active

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States camoa

Live updates comments and jobs are added and updated live.
  • API addition

    Enhances an existing API or introduces a new subsystem. Depending on the size and impact, possibly backportable to earlier major versions.

Sign in to follow issues

Comments & Activities

  • Issue created by @camoa
  • πŸ‡ΊπŸ‡ΈUnited States camoa
  • πŸ‡ΊπŸ‡ΈUnited States camoa

    Call Salesforce API action implemented and committed.

    What it does: Make direct calls to any Salesforce REST API endpoint with full response access. Supports standard REST API, custom Apex endpoints, Composite API, and more. No more custom code needed for complex Salesforce integrations.

    Key features:

    • All HTTP methods: GET, POST, PUT, PATCH, DELETE
    • Automatic path detection (relative for standard API, absolute for Apex)
    • Request body support with JSON validation
    • Custom headers configuration
    • Full response object access (MDVIP compatible)

    Available tokens:

    • Response data: [token:data] (parsed JSON), [token:raw_body] (raw string)
    • HTTP metadata: [token:status_code], [token:reason_phrase], [token:protocol_version]
    • Headers: [token:headers] (all), [token:content_type], [token:api_usage] (Sforce-Limit-Info)
    • Status flags: [token:success] (1 if 2XX), [token:is_json]
    • SObject helpers: [token:fields:FieldName], [token:record_id], [token:sobject_type]
    • Error handling: [token:error], [token:request_endpoint], [token:request_method]

    Example usage:

    • Get record: sobjects/Account/001D000000AbcDE
    • SOQL query: query?q=SELECT Id, Name FROM Contact LIMIT 10
    • Custom Apex: /services/apexrest/MyService/method
    • Composite API: composite/tree/Account

    Testing: Successfully tested with multiple endpoints. Response tokens properly populated, status codes accessible, API usage tracking working. Created test controller and Drush commands for easy testing.

    Files added/changed:

    • src/Plugin/Action/SalesforceCallApi.php (new action)
    • config/schema/salesforce_eca.schema.yml (configuration schema)
    • src/Controller/SalesforceEcaTestController.php (test controller)
    • src/Commands/SalesforceEcaCommands.php (Drush commands)

    Now you can call any Salesforce API endpoint directly from ECA workflows without writing custom code. This enables complex integrations like custom Apex calls, bulk operations, and advanced error handling.

    • camoa β†’ committed c2fb51aa on 1.0.x
      Issue #3529277 by camoa: Add "Call Salesforce API" action
      
Production build 0.71.5 2024