Skip to main content

Document Queue

Document Queue is a framework-level document intake workflow in Frappe that allows users to upload, extract, review, and process documents before creating records in another DocType. It provides a structured review process while keeping extraction and document creation separate.

Purpose

Document Queue handles document intake and text extraction, while applications such as ERPNext can build their own mapping, validation, and automation on top of the extracted data.

When to Use Document Queue

Document Queue is useful whenever users receive documents first and decide what records to create afterwards.

Common use cases include:

  • Uploading vendor invoices before creating Purchase Invoices.
  • Uploading expense receipts before creating Expense Claims.
  • Collecting signed forms, identity documents, or application files.
  • Importing documents from email inboxes or bulk upload workflows for later review.

It provides a consistent intake process while allowing applications to decide how extracted information should be used.

How Document Queue Works

Each Document Queue record represents a single uploaded source file. Along with the file, it stores extraction status, extracted text, raw extraction results, debugging information, and links to the final document created during review.

The typical workflow is:

  1. Upload a PDF or image to Document Queue.
  2. Run document extraction.
  3. Frappe extracts readable text and stores it.
  4. The record becomes Ready for Review.
  5. Start the review process and choose a target DocType if required.
  6. Fill the target document using the review panel.
  7. Save the document.
  8. Frappe links the Document Queue record to the created document and marks it as completed.

Document Queue Statuses

Status Description
Draft The record has been created but extraction has not started.
Queued The extraction request has been placed in the background queue.
Processing The uploaded document is currently being processed.
Ready for Review Extraction completed successfully and the document is ready for review.
Completed The review process finished and the target document has been created.
Failed Extraction failed or the uploaded file format is unsupported.

Completed records cannot be reviewed again, ensuring a one-to-one relationship between a queue record and its resulting document.

Document Extraction

Document Queue supports extraction from both PDF files and images.

PDF Extraction

PDF documents are processed using pdfplumber. The extracted text is stored separately while detailed extraction data is saved as raw JSON.

The extraction output can include:

  • Page number
  • Page dimensions
  • Extracted plain text
  • Layout-aware text
  • Detected words with coordinates
  • Detected tables

If embedded text extraction is insufficient, Frappe can perform OCR using Tesseract, provided the required system dependencies are installed.

Image Extraction

Images are processed using Tesseract OCR. The extracted text, along with detected word positions, is stored inside the raw extraction JSON.

Unsupported file formats automatically move to the Failed status, with error information stored in the record for troubleshooting.

Manual Document Queue Workflow

Creating a Queue Record

  1. Open the Document Queue list.
  2. Create a new record.
  3. Attach a PDF or image in Source File.
  4. Save the document.
  5. Click Extract.

After successful extraction, the record automatically moves to the Ready for Review state.

Creating the Target Document

  1. Open a Ready for Review record.
  2. Click Start Review.
  3. Select the target DocType if one has not already been defined.
  4. Review the extracted content while filling the target document.
  5. Save the target document.

After saving, Frappe automatically:

  • Marks the queue record as Completed.
  • Links it with the target document.
  • Moves the uploaded file to the target document’s attachments.

Review Panel

The review interface displays alongside the native Frappe form.

It contains two tabs:

  • Preview – Displays the uploaded PDF or image.
  • Extraction – Displays the extracted text.

The preview panel can be resized, and its width preference is remembered in the browser for future sessions.

If the user closes the target document before saving, the Document Queue record remains available for review later.

Upload-First Workflow

Administrators can enable an upload-first workflow for supported DocTypes.

When enabled:

  • Users upload a document before filling the form.
  • Frappe creates a Document Queue record automatically.
  • The uploaded file is extracted.
  • The review interface opens together with the new document.

Enable Upload-First Workflow

  1. Open the required DocType.
  2. Enable Upload First Workflow.
  3. Save the DocType.

Only DocTypes with this option enabled appear in the Document Queue target selector.

Ready for Review Banner

When Upload First Workflow is enabled, supported DocTypes can display a banner indicating how many documents are waiting for review.

For example:

3 Documents ready for review

The banner provides a shortcut to filtered Document Queue records awaiting review.

Permissions

By default:

  • System Manager has full access to Document Queue records.
  • Desk Users can create and access records they own.
  • Users must also have permission to create records for the selected target DocType.

Developer API

Queue Extraction

Run document extraction as a background job.

from frappe.core.doctype.document_queue.document_queue import enqueue_document_extraction

task = enqueue_document_extraction(document_queue_name)

Immediate Extraction

Extract the document immediately within the current request.

from frappe.core.doctype.document_queue.document_queue import extract_document_queue_record

result = extract_document_queue_record(document_queue_name)

Review Context

Retrieve all information required by the review interface.

from frappe.core.doctype.document_queue.document_queue import get_document_review_context

context = get_document_review_context(document_queue_name)

Link Queue Record to a Document

Associate a completed queue record with its target document.

from frappe.core.doctype.document_queue.document_queue import link_to_document

link_to_document(
    document_queue=document_queue_name,
    document_type="Address",
    document_name=address_name,
)

Ready for Review Count

Retrieve the number of documents waiting for review for a specific DocType.

from frappe.core.doctype.document_queue.document_queue import get_ready_for_review_count

count = get_ready_for_review_count("Address")

Extending Document Queue

Document Queue intentionally focuses only on document intake, extraction, and review. Business-specific logic should be implemented by applications built on top of it.

Applications can extend it by:

  • Processing completed queue records.
  • Using extracted text for manual review.
  • Reading raw extraction JSON for coordinates and tables.
  • Adding field mapping suggestions.
  • Performing custom validation before or after document creation.
  • Creating queue records from emails or bulk uploads.

Limitations

  • Does not perform AI or LLM-based field extraction.
  • Does not automatically map extracted values to DocType fields.
  • Does not support CSV or spreadsheet extraction.
  • OCR requires external tools such as Tesseract and PDF OCR fallback requires pdftoppm.
  • Extraction accuracy depends on the quality of the uploaded document.

Best Practice

Use Document Queue as the standardized document intake layer for your applications. Keep document extraction within the framework while implementing field mapping, validation, and business-specific automation inside your own applications to maintain flexibility and separation of responsibilities.

Rating: 0 / 5 (0 votes)