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ài Viết → Tạo Mới

AI-generated

Overview

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

For the Bài Viết (Articles) resource with the Tạo Mới (Create) operation, the node creates a new custom metafield attached to a specific article identified by its resource ID. This is useful when you want to add extra metadata to articles, such as categorization tags, SEO keywords, or any custom attribute not natively supported.

Practical example:
You have an article in your Sapo store and want to add a custom field "warehouse_location" under the namespace "inventory" to track where related physical materials are stored. Using this node, you specify the article ID and provide the metafield data JSON to create this custom field.

Properties

Name Meaning
ID Tài Nguyên The numeric ID of the article resource to which the metafield will be attached.
Dữ Liệu Trường Tùy Chỉnh A JSON object defining the metafield details. It includes:
- namespace: grouping category for the metafield (e.g., "inventory")
- key: the metafield key name (e.g., "warehouse_location")
- value: the value assigned to the metafield (e.g., "A-12")
- value_type: type of the value (e.g., "string")
- description: optional description of the metafield's purpose

Output

The output is a JSON object representing the created metafield returned from the Sapo API. It typically contains all properties of the newly created metafield, including its unique identifier, namespace, key, value, value type, description, and association to the specified article.

Example output structure (simplified):

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

No binary data output is involved in this operation.

Dependencies

  • Requires an active connection to the Sapo API via an API authentication credential configured in n8n.
  • The node depends on the internal SapoApiBase class to interact with the metafields endpoint of the Sapo API.
  • Proper permissions on the Sapo account to create metafields on articles.

Troubleshooting

  • Common issues:

    • Invalid or missing resource ID: Ensure the article ID provided exists and is correct.
    • Malformed JSON in the metafield data property: Validate the JSON format before execution.
    • Insufficient API permissions: Verify that the API key has rights to modify metafields.
    • Namespace/key conflicts: Avoid duplicate keys within the same namespace for the same resource.
  • Error messages:

    • "error": "Resource not found": The specified article ID does not exist.
    • "error": "Invalid metafield data": The JSON data is missing required fields or has invalid types.
    • API authentication errors: Check API credentials and connectivity.

To resolve errors, verify input parameters, ensure valid JSON, and confirm API access rights.

Links and References

Discussion