Actions109
- Activity Actions
- Assets Actions
- Authentication Actions
- Collections Actions
- Extensions Actions
- Fields Actions
- Files Actions
- Folders Actions
- Items Actions
- Permissions Actions
- Presets Actions
- Relations Actions
- Revisions Actions
- Roles Actions
- Settings Actions
- Users Actions
- Utilities Actions
- Webhooks Actions
Utilities → Sort Items
AI-generatedOverview
The Utilities → Sort Items operation in this custom n8n node for Directus allows you to reorder items within a specified collection. By specifying the primary key of an item and the target position (also by primary key), you can move an item to a new location in the collection's order.
Common scenarios:
- Reordering articles, products, or any sortable entities in a CMS or database managed by Directus.
- Automating workflows where the display order of items matters, such as featured lists, menus, or prioritized tasks.
Practical example:
Suppose you have a list of blog posts and want to move post with ID 16 to the position after post with ID 51 in the "author" collection. This operation automates that reordering.
Properties
| Name | Type | Meaning |
|---|---|---|
| To | Number | Primary key of the item where you want to move the current item to. |
| Item | Number | Primary key of the item you want to move. |
| Collection | Options | Identifier of the collection containing the items to be reordered. |
Output
The output is a JSON object reflecting the result of the sort operation. The structure may vary depending on the API response, but typically includes:
{
"result": <operation result>
}
- If the API returns a simple value (string, number, boolean), it will be wrapped in a
resultfield. - If the API returns an object, its fields will be included directly in the output JSON.
Dependencies
- Directus API: Requires access to a Directus instance.
- API Credentials: You must configure the
directusApicredentials in n8n for authentication.
Troubleshooting
Common issues:
- Invalid IDs: If either the "Item" or "To" primary keys do not exist in the specified collection, the operation will fail.
- Permission errors: Ensure your API credentials have permission to update the collection and reorder items.
- Collection not found: If the collection identifier is incorrect or missing, the operation will not succeed.
Error messages and resolutions:
"error": "Item not found": Check that both "Item" and "To" refer to valid primary keys in the selected collection."error": "Unauthorized": Verify your Directus API credentials and permissions."error": "Collection does not exist": Double-check the collection name/identifier.