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

Bộ Sưu Tập → Tạo Mới

AI-generated

Overview

This node manages custom metafields on various resource types within the Sapo platform. Metafields are additional data fields that users can define to extend the default properties of resources such as collections, products, customers, orders, and more.

The "Create New" operation for the "Bộ Sưu Tập" (Collection) resource allows users to add a new custom metafield to a specific collection by specifying its namespace, key, value, type, and description.

Common scenarios:

  • Adding extra metadata to collections for inventory management or categorization.
  • Storing custom attributes like warehouse location, supplier codes, or internal notes.
  • Extending the data model without modifying the core resource schema.

Example:
Creating a metafield on a collection with:

  • Namespace: inventory
  • Key: warehouse_location
  • Value: A-12
  • Value Type: string
  • Description: Storage location in warehouse

This helps track where items in the collection are physically stored.


Properties

Name Meaning
ID Tài Nguyên The numeric ID of the collection resource to which the metafield will be added.
Dữ Liệu Trường Tùy Chỉnh JSON object defining the metafield details including:
- namespace: Grouping identifier
- key: Unique key name
- value: The actual data stored
- value_type: Data type of the value (e.g., string)
- description: Explanation of the metafield's purpose

Example of Dữ Liệu Trường Tùy Chỉnh property value:

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

Output

The output is a JSON object representing the created metafield returned from the Sapo API. It typically includes all metafield properties such as:

  • id: The unique identifier of the metafield.
  • namespace, key, value, value_type, description: The metafield details as provided.
  • owner_type: The resource type (here, "collection").
  • owner_id: The ID of the collection resource.

If the operation fails and "Continue On Fail" is enabled, the output will contain an error message under the error field.

No binary data is produced by this node.


Dependencies

  • Requires an active connection to the Sapo API via an API authentication credential configured in n8n.
  • The node depends on the bundled SapoApiBase class to perform REST API calls to manage metafields.
  • Proper permissions on the Sapo account to create metafields on collections are necessary.

Troubleshooting

  • Common issues:

    • Invalid or missing resourceId will cause the API call to fail.
    • Malformed JSON in the data property may result in parsing errors or API rejection.
    • Insufficient permissions or invalid API credentials will lead to authorization errors.
  • Error messages:

    • "error": "Resource not found": Check if the collection ID exists.
    • "error": "Invalid metafield data": Verify the JSON structure and required fields.
    • "error": "Unauthorized": Confirm API credentials and permissions.
  • Resolution tips:

    • Validate JSON input before running the node.
    • Ensure the collection ID corresponds to an existing collection.
    • Verify API credentials and their scopes.
    • Enable "Continue On Fail" to handle errors gracefully in workflows.

Links and References

Discussion