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

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 can be attached to resources such as products, orders, customers, blogs, and more, allowing users to extend the default data model with custom information.

The node supports operations like creating new metafields, retrieving single or multiple metafields, updating, deleting (single or bulk), counting metafields, and validating metafield values.

Common scenarios:

  • Adding custom metadata to products, e.g., warehouse location or supplier codes.
  • Retrieving and managing metafields for orders or customers to enhance reporting or integration.
  • Validating metafield values before saving to ensure data integrity.

Practical example:
Creating a new metafield on a product resource to store the warehouse location:

  • Resource: Product
  • Operation: Create
  • Resource ID: The product's ID
  • Data: JSON describing the metafield namespace, key, value, type, and description.

Properties

Name Meaning
Thao Tác (operation) The action to perform on the metafield. Options: Bulk Delete, Count, Create, Delete, Get, Get Many, Update, Validate.
Tài Nguyên (resource) The resource type to which the metafield belongs. Options: Articles, Blog, Collections, Customers, Orders, Pages, Products, Variants.
ID Tài Nguyên (resourceId) The unique identifier of the resource instance to manage metafields for.
ID Trường Tùy Chỉnh (metafieldId) The unique identifier of the metafield (required for get, update, delete operations).
Trả Về Tất Cả (returnAll) Whether to return all metafields or limit the number of results (for getMany operation).
Giới Hạn (limit) Maximum number of metafields to return when not returning all (for getMany operation).
Thông Tin Bổ Sung (additionalFields) Additional filters or parameters such as namespace, key, creation date range for list, count, or bulk delete operations.
Dữ Liệu Trường Tùy Chỉnh (data) JSON object defining the metafield data to create or update. Includes namespace, key, value, value_type, description. Required for create and update.
Tùy Chọn Xác Thực (validationData) JSON object containing data to validate a metafield value without saving it. Used in validate operation.

Output

The node outputs an array with one item per execution containing a json field with the result of the operation:

  • For create, get, update: The JSON contains the metafield object returned by the API.
  • For getMany: The JSON contains a list of metafields, possibly filtered and limited.
  • For delete: Returns { success: true } upon successful deletion.
  • For bulkDelete: Returns the result of the bulk delete operation.
  • For count: Returns { count: <number> } indicating how many metafields match the criteria.
  • For validate: Returns { valid: true } if the validation passes.
  • On error (if "Continue On Fail" is enabled), returns { error: "<error message>" }.

The node does not output binary data.

Dependencies

  • Requires an active connection to the Sapo API via an API authentication credential configured in n8n.
  • Uses an internal Sapo API base helper class to interact with metafields endpoints.
  • No other external dependencies.

Troubleshooting

  • Common issues:

    • Invalid or missing resource ID or metafield ID will cause API errors.
    • Malformed JSON in the data property for create/update operations may cause failures.
    • Insufficient permissions or invalid API credentials will result in authorization errors.
    • Using unsupported resource types or operations may lead to unexpected errors.
  • Error messages:

    • Errors from the Sapo API are caught and either thrown or returned as error objects depending on the node's "Continue On Fail" setting.
    • Typical errors include "Resource not found", "Invalid metafield data", or "Unauthorized".
  • Resolution tips:

    • Verify resource IDs and metafield IDs are correct and exist.
    • Ensure JSON input for metafield data is well-formed and matches expected schema.
    • Confirm API credentials have necessary permissions.
    • Use the "Validate" operation to check metafield data before attempting to create or update.

Links and References

Discussion