How to Upload a Zoho Books Invoice to Zoho Creator and Download into Local System

How to Upload a Zoho Books Invoice to Zoho Creator and Download into Local System

Introduction

What you'll learn: How to automatically fetch an invoice PDF from Zoho Books, upload it to a Zoho Creator record, generate a public download link, and deliver it to users — all through a single Deluge function.

Finance teams working with Zoho Books often need to share or archive invoice PDFs quickly. Manually downloading each invoice and attaching it to a Creator record is time-consuming and prone to human error. In this tutorial, you will learn how to automate the entire flow — from fetching the invoice PDF via the Zoho Books API to delivering a ready-to-download link inside Zoho Creator.

⚙️ Prerequisites

  • A Zoho Creator application with an Invoices form containing fields: Invoice_ID, Organization_ID, Invoice_No, and a File Upload field
  • Zoho Books with existing invoice records
  • API connections configured in Creator (details in Step 1 below)
  • Your Creator report published with a Perma Link

The Use Case

Your business stores invoice metadata in Zoho Creator — things like Invoice ID, Invoice Number, and Organisation ID. When a user needs the actual invoice PDF (stored in Zoho Books), they currently switch apps, search for the invoice, download it manually, and re-attach it. With this automation:

  • A Deluge function fetches the invoice PDF directly from Zoho Books
  • It uploads the file to the matching Creator record
  • A public download link is generated and returned
  • The user gets the file without leaving Creator

How the Process Works

1The Deluge function retrieves the invoice record from Zoho Creator
2It calls the Zoho Books API to fetch the invoice PDF using the Invoice ID and Organisation ID
3The PDF is uploaded to the File Upload field of the Creator record
4A public download URL is built using the Creator Perma Link token
5The link is returned to the user for immediate download

Step 1: Set Up Two API Connections in Zoho Creator

Before writing any code, you need two configured connections inside Zoho Creator:

Connection 1Zoho Books

  • Name suggestion: zoho_books
  • Purpose: Authenticate and fetch invoice PDFs from the Zoho Books API
  • Required scopes: ZohoBooks.invoices.READ

Connection 2Zoho Creator

  • Name suggestion: zcreator
  • Purpose: Upload files to the Creator File Upload field via the Creator API
  • Required scopes: ZohoCreator.report.UPDATE

Step 2: Create the Invoices Form in Zoho Creator

Open your Zoho Creator application and create a new form named Invoices. This form acts as the bridge between your Zoho Books data and the automation — it stores the invoice metadata that the Deluge function will use to fetch and upload the correct PDF.

Add the following fields to the form:

1

Organisation ID  Number / Text

Stores the unique Organisation ID from Zoho Books. This is passed to the Books API to identify which organisation the invoice belongs to. Link name: Organization_ID

2

Organisation Name  Single Line

Stores the name of the organisation for display and reference purposes. Link name: Organisation_Name

3

Invoice Number  Single Line

The human-readable invoice number (e.g., INV-00123). This is used to name the downloaded PDF file automatically. Link name: Invoice_No

4

Invoice Book ID  Number (Long)

The unique numeric Invoice ID assigned by Zoho Books. This is the key identifier sent to the Books API to fetch the correct PDF. Use Long / Number field type to handle large numeric IDs without precision loss. Link name: Invoice_ID

5

File Upload  File Upload

This is where the fetched invoice PDF will be stored after the Deluge function runs. The field path is also used to construct the public download URL. Link name: File_upload

 Important: The link names (e.g., Invoice_ID, Organization_ID, Invoice_No, File_upload) must match exactly as used in the Deluge script. If you rename them, update the script accordingly.

Step 3: Publish Your Creator Report & Get the Perma Link

Your All Invoices report must be published so the public download URL works.

For Creator 6.0: Creator Home → Operations → Publish → Select Application → Choose All Invoices

For Creator 5.0: Application → Edit Application → Settings → Publish → Publish Component → Select All Invoices

After publishing, copy the Perma Link. It will look like this:

https://creatorapp.zohopublic.com/your_account/app_name/report-perma/All_Invoices/xxxxxx

Save the token at the end (after All_Invoices/) — you will need it in the script.

Step 4: Add a Custom Button to the Invoices Report

Open the All Invoices report in your Creator application and add a Custom Button (e.g., labeled "Download Invoice"). Configure it to trigger the Deluge function you will write in the next step. This button is what users will click to fetch and download the invoice PDF for any selected record without leaving Zoho Creator.

Step 5: Write the Deluge Custom Function

Create a new Deluge function in your Creator application. This is the core of the automation — it handles fetching, uploading, and link generation in one go.

string Download_PDF_Function(int invoiceID)
{
    //--- 1. Retrieve the Invoice Record from Creator ---//
    inv = Invoices[ID == invoiceID];

    invoiceID_v = inv.Invoice_ID;          // Zoho Books numeric Invoice ID
    Organization_ID = inv.Organization_ID; // Zoho Books Organisation ID


    //--- 2. Fetch the Invoice PDF from Zoho Books ---//
    url_v = "https://www.zohoapis.com/books/v3/invoices/pdf"
            + "?organization_id=" + Organization_ID
            + "&invoice_ids=" + invoiceID_v;

    documentObj = invokeurl
    [
        url : url_v
        type : GET
        connection : "zoho_books"
    ];

    documentObj.setparamname("file");
    fileName = inv.Invoice_No + ".pdf";
    documentObj.setFileName(fileName);


    //--- 3. Upload the PDF to the Creator File Upload Field ---//
    account_owner_name = zoho.appuri;

    upload_url = "https://www.zohoapis.com/creator/v2/data"
                 + account_owner_name
                 + "report/All_Invoices/"
                 + invoiceID
                 + "/File_upload/upload";

    response = invokeurl
    [
        url : upload_url
        type : POST
        files : documentObj
        connection : "zcreator"
    ];

    info response;


    //--- 4. Generate and Return the Public Download Link ---//
    if(response.getJSON("data").size() > 0)
    {
        file = response.getJSON("data").getJSON("filepath");
        info file;

        // Replace "xxxxxx" with your Perma Link token
        token = "xxxxxx";

        download_link_public = "https://creatorapp.zohopublic.com/file"
                               + account_owner_name
                               + "All_Invoices/"
                               + invoiceID
                               + "/File_upload/download/"
                               + token
                               + "?filepath=/"
                               + file;

        return download_link_public;
    }

    return "No file Upload";
}

Understanding the Script — Section by Section

Section 1: Fetch the Creator Record

The function receives invoiceID (the Creator record ID). It queries the Invoices form to retrieve the Zoho Books Invoice ID and Organisation ID needed for the API call.

Section 2: Call the Zoho Books API

The Zoho Books /invoices/pdf endpoint accepts an organization_id and invoice_ids parameter, returning the invoice as a binary PDF. The connection zoho_books handles the OAuth token automatically.

The PDF is assigned a proper filename using the Invoice Number:

documentObj.setFileName(inv.Invoice_No + ".pdf");

Section 3: Upload to Creator

The PDF is uploaded to the Creator File Upload field via a POST request. The URL targets the specific record (by invoiceID) and field (File_upload) within the All_Invoices report.

Section 4: Build & Return the Download Link

After a successful upload, the response contains the file path inside Creator. The function constructs a public download URL using:

  • Your account owner name (zoho.appuri)
  • The Perma Link token from your published report
  • The file path returned in the upload response

This URL is returned as a string that can be used to trigger the download from a button or workflow.

 Important: Replace "xxxxxx" with the actual token from your published report's Perma Link. Also confirm that File_upload matches the exact link name of your File Upload field in Creator.

Connecting This to a Button (Optional)

To trigger this function from a report button, add a Custom Button to your All Invoices report in Creator. In the button's action, call Download_PDF_Function with the current record's ID, then use openUrl() to open the returned link in a new window:

// Example: calling from a button action
link = Download_PDF_Function(input.ID);
openUrl(link, "new window");

Expected Output

✅ Invoice PDF is fetched automatically from Zoho Books

✅ PDF is uploaded to the Creator record's File Upload field

✅ A public download link is generated and returned

✅ Users can access the invoice PDF without switching between apps

Common Errors & Fixes

Problem Likely Cause Fix
File not downloading Wrong Perma Link token or malformed download URL Re-check the published report token and rebuild the URL string
Zoho Books API returns error Wrong Invoice ID format or missing Organisation ID Log the values with info and confirm they match Zoho Books records
Upload fails with 4xx error Incorrect field name or Creator connection scopes Verify the field link name and ensure the zcreator connection has update access
Function returns "No file Upload" Upload response data is empty Check the upload URL structure and confirm the report name matches exactly

Pro Tips

  • Always use info response; during development to inspect the upload API response — it reveals the exact file path needed for the download URL.
  • Keep Invoice IDs as Long type in Creator to avoid numeric precision issues with large Zoho Books IDs.
  • If you have multiple organisations in Zoho Books, store the Organization_ID per invoice in Creator rather than hardcoding it.
  • Secure your connections by regularly reviewing API scope permissions in the Zoho Developer console.

Who Is This For?

  • Finance teams who need instant access to invoice PDFs from within Creator
  • Zoho developers building unified document management workflows
  • Businesses using Zoho Books + Creator together for billing and operations
  • Automation engineers eliminating manual cross-app file transfers

Wrapping Up

Connecting Zoho Books and Zoho Creator through Deluge gives your finance team a seamless way to access and download invoices without ever leaving their workspace. The four-step flow — fetch, upload, link, download — is clean, reliable, and easy to maintain.

Looking for a similar setup with generated reports instead of invoices? Check out our companion tutorial: How to Download a Zoho Writer Merged Document to Your Local System from Zoho Creator.

Post a Comment