Overview
This node integrates with the KiotViet platform to manage orders. It supports operations such as creating new orders, retrieving orders by ID or code, listing multiple orders with filters, updating existing orders, and canceling orders. This node is useful for automating order management workflows, syncing order data between KiotViet and other systems, or building custom order processing pipelines.
Practical examples include:
- Automatically fetching order details by ID to update internal databases.
- Creating new orders in KiotViet based on external sales channels.
- Canceling orders programmatically when certain conditions are met.
- Retrieving a filtered list of orders for reporting or batch processing.
Properties
| Name | Meaning |
|---|---|
| Thao Tác (operation) | The action to perform on orders. Options: Hủy (cancel), Tạo Mới (create), Lấy Theo ID (get), Lấy Theo Mã (getByCode), Lấy Danh Sách (getAll), Cập Nhật (update) |
| Trả Về Tất Cả (returnAll) | Whether to return all results or limit the number of results (only for "Lấy Danh Sách") |
| Giới Hạn (limit) | Maximum number of results to return when not returning all (only for "Lấy Danh Sách") |
| ID ĐƠN Hàng (orderId) | The unique identifier of the order (required for get, update, cancel operations) |
| Mã ĐƠN Hàng (orderCode) | The code of the order (required for getByCode operation) |
| Lý Do Hủy (cancelReason) | Reason for canceling the order (optional for cancel operation) |
| ID Chi Nhánh (branchId) | Branch ID where the order is created (required for create operation) |
| Sản Phẩm Trong ĐƠN (orderProducts) | List of products in the order, each with: ID Sản Phẩm (productId), Số Lượng (quantity), Giá Bán (price), Giảm Giá (discount), Ghi Chú (note) (used in create and update operations) |
| Bộ Lọc (filters) | Filters for listing orders including: Trang (pageSize), Số Trang (currentPage), ID Chi Nhánh (branchId), Từ Ngày (fromDate), Đến Ngày (toDate), Trạng Thái (status: Completed, Cancelled, Processing) (only for getAll operation) |
| Trường Bổ Sung (additionalFields) | Additional optional fields for create and update operations: ID Khách Hàng (customerId), Mô Tả (description), Giảm Giá (discount) |
Output
The node outputs JSON data representing the result of the selected operation:
- For get, getByCode, create, update, and cancel operations, the output is the detailed order object returned from KiotViet API.
- For getAll, the output includes an array of order objects along with pagination metadata such as total count and page size.
- If an error occurs and "continue on fail" is enabled, the output will contain an error message object for the failed item.
The node does not output binary data.
Dependencies
- Requires an API key credential for authenticating with the KiotViet API.
- Uses the KiotViet API client implemented in the shared module to perform HTTP requests.
- No additional environment variables are explicitly required beyond the API credential.
Troubleshooting
Common issues:
- Invalid or missing order ID or order code parameters can cause errors.
- Attempting unsupported operations if the KiotViet API client does not implement them (e.g., update or cancel).
- Network or authentication failures due to incorrect API credentials.
Error messages:
"Update operation is not supported by the KiotViet API"or"Cancel operation is not supported by the KiotViet API"indicate that the API client lacks these methods; verify API version or node implementation.- Errors related to parsing IDs (e.g.,
parseIntfailures) suggest invalid input format; ensure numeric IDs are provided correctly. - API response errors will be surfaced with their message; check API permissions and request parameters.
Resolution tips:
- Double-check required parameters for each operation.
- Ensure the API credential is valid and has necessary permissions.
- Use "continue on fail" option to handle partial failures gracefully during batch executions.
Links and References
- KiotViet Official Website
- KiotViet API Documentation (for detailed API capabilities and limitations)
- n8n documentation on Creating Custom Nodes