Actions3
- Agenda Actions
- Task Actions
- Document Actions
Overview
This node allows you to create a new document in Dolibarr, an open-source ERP and CRM system. It is useful for automating the process of attaching files (such as invoices, reports, or proposals) to various Dolibarr modules (e.g., Agenda, Invoice, Project). Typical scenarios include uploading generated PDFs, storing signed contracts, or programmatically archiving documents related to business processes.
Example use cases:
- Automatically attach a generated invoice PDF to a customer record.
- Upload scanned receipts to expense reports.
- Store project documentation directly from another workflow.
Properties
| Name | Meaning |
|---|---|
| File Name | The name of the file to be created in Dolibarr. This is required. |
| Module Name | The Dolibarr module to which the document will be attached. Options: Agenda, Expense Report, Invoice, Member, Order, Product, Project, Proposal, Supplier Invoice, Supplier Order, Task. |
| Reference | The reference (ID or code) of the object within the selected module to which the document will be attached. This is required. |
| File Content | The content of the file to upload. Typically provided as a string (can be base64 encoded if needed). |
| Additional Fields | Optional settings: |
| - File Encoding | If enabled, sets the file encoding to "base64". Otherwise, leaves it empty. |
| - Overwrite File if It Already Exists ? | If enabled, overwrites the file if one with the same name already exists (1 = yes, 0 = no). |
| - Create Subdirectories if Necessary ? | If enabled, creates subdirectories if they do not exist (1 = yes, 0 = no). |
Output
The output will contain a json field with the response from Dolibarr's API after attempting to create the document. The structure typically includes:
- Information about the created document (such as its ID, filename, and location).
- Any status or error messages returned by Dolibarr.
If binary data is involved (e.g., file uploads), the node handles the file content as specified in the input properties, but the output itself is JSON summarizing the result.
Dependencies
- External Service: Requires access to a Dolibarr instance with API enabled.
- API Credentials: You must configure n8n with valid Dolibarr API credentials (
dolibarrApi). - Environment Variables: The base URL for Dolibarr must be set in the credentials.
Troubleshooting
Common Issues:
- Invalid Reference: If the provided reference does not match any object in the selected module, the API may return an error indicating that the object was not found.
- File Already Exists: If "Overwrite File if It Already Exists ?" is disabled and a file with the same name exists, the operation may fail.
- Incorrect File Content/Encoding: If the file content is not properly encoded (e.g., missing base64 when required), the uploaded file may be corrupted or rejected.
- Missing Required Fields: Omitting required fields like File Name, Module Name, or Reference will result in validation errors.
Error Messages:
"Object not found": Check that the Reference matches an existing item in the chosen module."File already exists": Enable overwrite or choose a different file name."Invalid file content": Ensure the file content is correctly formatted and encoded.