Trying to make zoho invoice have a button

Trying to make zoho invoice have a button

Hello

I am getting this error with the code below. Anyone know how to fix?

  • Check and update the code in line 5 as there is a Exception : Variable 'invoice_id' is not defined

// Define Organization ID (Replace with your actual Zoho Invoice organization ID)
organizationID = "YOUR_ORG_ID"; // Replace with your Zoho Invoice organization ID

// Ensure invoice_id is passed correctly
if(input.invoice_id == null || input.invoice_id == "")
{
    return "Error: Invoice ID is missing.";
}

invoiceID = input.invoice_id.toString(); // Assigning the invoice ID from input

// Fetch Invoice details
invoiceDetails = zoho.invoice.getRecordById("Invoices", invoiceID, organizationID);

// Check if invoice details are retrieved successfully
if(invoiceDetails.contains("code") && invoiceDetails.get("code") != 0)
{
    return "Error retrieving invoice: " + invoiceDetails.get("message");
}

// Get Customer Email
customerEmail = invoiceDetails.get("customer_email");

// Ensure the email is available
if(customerEmail == null || customerEmail == "")
{
    return "Error: Customer email is missing for invoice " + invoiceID;
}

// Define recipient details
recipientMap = Map();
recipientMap.put("email", customerEmail);
recipientMap.put("action_type", "SIGNER");

// Define document details
documentMap = Map();
documentMap.put("template_id", "Agreement_Template_ID");  // Replace with actual template ID
documentMap.put("recipients", list(recipientMap));

// Send agreement for signature
signDocResponse = zoho.sign.createDocument(documentMap);

// Log response and add a note in invoice
if(signDocResponse.get("status") == "success")
{
    note = "Agreement sent for signature via Zoho Sign.";
    zoho.invoice.addNote("Invoices", invoiceID, note, organizationID);
    return "Agreement successfully sent for signature.";
}
else
{
    note = "Error in sending agreement: " + signDocResponse.toString();
    zoho.invoice.addNote("Invoices", invoiceID, note, organizationID);
    return note;
}

    Access your files securely from anywhere







                            Zoho Developer Community




                                                  • Desk Community Learning Series


                                                  • Digest


                                                  • Functions


                                                  • Meetups


                                                  • Kbase


                                                  • Resources


                                                  • Glossary


                                                  • Desk Marketplace


                                                  • MVP Corner


                                                  • Word of the Day


                                                  • Ask the Experts





                                                            Manage your brands on social media



                                                                  Zoho TeamInbox Resources



                                                                      Zoho CRM Plus Resources

                                                                        Zoho Books Resources


                                                                          Zoho Subscriptions Resources

                                                                            Zoho Projects Resources


                                                                              Zoho Sprints Resources


                                                                                Qntrl Resources


                                                                                  Zoho Creator Resources



                                                                                      Zoho CRM Resources

                                                                                      • CRM Community Learning Series

                                                                                        CRM Community Learning Series


                                                                                      • Kaizen

                                                                                        Kaizen

                                                                                      • Functions

                                                                                        Functions

                                                                                      • Meetups

                                                                                        Meetups

                                                                                      • Kbase

                                                                                        Kbase

                                                                                      • Resources

                                                                                        Resources

                                                                                      • Digest

                                                                                        Digest

                                                                                      • CRM Marketplace

                                                                                        CRM Marketplace

                                                                                      • MVP Corner

                                                                                        MVP Corner









                                                                                          Design. Discuss. Deliver.

                                                                                          Create visually engaging stories with Zoho Show.

                                                                                          Get Started Now


                                                                                            Zoho Show Resources

                                                                                              Zoho Writer

                                                                                              Get Started. Write Away!

                                                                                              Writer is a powerful online word processor, designed for collaborative work.

                                                                                                Zoho CRM コンテンツ



                                                                                                  Nederlandse Hulpbronnen


                                                                                                      ご検討中の方