Sapo Trường Tùy Chỉnh icon

Sapo Trường Tùy Chỉnh

Quản lý trường tùy chỉnh trên Sapo

Đơn Hàng → Tạo Mới

AI-generated

Overview

This node manages custom metafields on various resources within the Sapo platform, specifically allowing creation, retrieval, updating, deletion, counting, bulk deletion, and validation of metafields. Metafields are additional custom fields that extend the data model of standard resources like orders, products, customers, etc.

For the "Đơn Hàng" (Orders) resource with the "Tạo Mới" (Create) operation, the node creates a new custom metafield attached to a specific order identified by its ID. This is useful when you want to add extra metadata or custom attributes to an order beyond the default fields provided by Sapo.

Practical examples:

  • Adding a warehouse location code to an order for internal tracking.
  • Storing special instructions or tags related to order processing.
  • Attaching custom flags or statuses that integrate with other systems.

Properties

Name Meaning
ID Tài Nguyên The numeric ID of the resource (order) to which the metafield will be attached.
Dữ Liệu Trường Tùy Chỉnh JSON object defining the metafield details including:
- namespace: Logical grouping of the metafield.
- key: Identifier name of the metafield.
- value: The actual value to store.
- value_type: Data type of the value (e.g., string).
- description: Human-readable description of the metafield's purpose.

Example of the data property JSON:

{
  "namespace": "inventory",
  "key": "warehouse_location",
  "value": "A-12",
  "value_type": "string",
  "description": "Storage location in warehouse"
}

Output

The node outputs an array with one element containing a json object representing the result of the create operation. This typically includes the newly created metafield's details as returned by the Sapo API.

Example output structure:

[
  {
    "json": {
      "id": 12345,
      "namespace": "inventory",
      "key": "warehouse_location",
      "value": "A-12",
      "value_type": "string",
      "description": "Storage location in warehouse",
      "owner_type": "order",
      "owner_id": 67890
    }
  }
]

No binary data output is produced by this node.

Dependencies

  • Requires an active connection to the Sapo API via an API key credential configured in n8n.
  • The node depends on the bundled SapoApiBase class to handle API requests.
  • Proper permissions on the Sapo account to create metafields on orders.

Troubleshooting

  • Common issues:

    • Invalid or missing resource ID: Ensure the order ID provided exists and is correct.
    • Malformed JSON in the data property: The metafield JSON must be valid and include all required fields (namespace, key, value, value_type).
    • Insufficient API permissions: The API key used must have rights to modify order metafields.
    • Network or authentication errors connecting to Sapo API.
  • Error messages:

    • Errors from the Sapo API will be surfaced with their message. For example, "Resource not found" indicates an invalid order ID.
    • JSON parsing errors if the data field is not valid JSON.
    • Authentication failures if the API key is invalid or expired.
  • Resolution tips:

    • Double-check the resource ID and ensure it corresponds to an existing order.
    • Validate the JSON syntax of the data input before running.
    • Verify API credentials and permissions.
    • Enable "Continue On Fail" in the node settings to handle errors gracefully during workflows.

Links and References

Discussion