Salesforce OpenCommerce API icon

Salesforce OpenCommerce API

OCAPI for Salesforce Commerce Cloud

Search Orders

AI-generated

Overview

The Search Orders operation of the Salesforce OpenCommerce API (OCAPI) n8n node allows users to search for orders within a specified Salesforce Commerce Cloud (SFCC) site. This is useful for retrieving order data based on custom queries, such as filtering by customer, date range, status, or other order attributes.

Common scenarios:

  • Integrating SFCC order data into other systems (e.g., CRM, ERP).
  • Automating reporting or analytics workflows that require order information.
  • Triggering downstream processes based on specific order criteria (e.g., high-value orders, unfulfilled orders).

Practical example:
A business wants to automatically pull all orders from the last 24 hours and send them to their accounting system for reconciliation.


Properties

Name Type Meaning
Site ID String The SFCC site ID (e.g., "SiteGenesis"). Identifies which site’s orders to search.
Select Fields String Specifies which fields to include in the response. Uses OCAPI field selection syntax.
Query JSON A JSON object defining the search criteria for orders (e.g., filters, conditions).

Output

The node outputs an array of objects, each with a json property containing the details of an individual order matching the search criteria.

Output structure example:

[
  {
    "json": {
      // Order fields as returned by OCAPI, e.g.:
      "order_no": "00012345",
      "customer_info": { ... },
      "status": "created",
      ...
    }
  },
  ...
]
  • Each item represents one order.
  • The exact fields depend on the "Select Fields" property and the OCAPI response.

Dependencies

  • External Service: Requires access to a Salesforce Commerce Cloud instance with OCAPI enabled.
  • Credentials: Needs valid n8n credentials for "salesforceOcapi" (clientId, clientSecret, hostname, version).
  • n8n Configuration: Credentials must be set up in n8n under the name "salesforceOcapi".

Troubleshooting

Common issues:

  • Invalid Credentials: If the provided credentials are incorrect or lack permissions, authentication will fail.
  • Malformed Query: If the "Query" property is not valid JSON or does not match OCAPI's expected format, errors will occur.
  • Field Selection Errors: If "Select Fields" contains invalid field names, the API may return errors or incomplete data.

Error messages and resolutions:

  • "Unexpected token ... in JSON at position ...": The "Query" input is not valid JSON. Double-check your query syntax.
  • "Authentication failed": Check your salesforceOcapi credentials in n8n.
  • "Field ... not found": Adjust your "Select Fields" value to use valid OCAPI field names.

Links and References

Discussion