Help with deluge script

Help with deluge script

            Hi Community, this is my first Deluge script. I've pieced it together from reading various articles
I want to use it in a workflow to 
1 Convert a lead to a contact
2. Create a record in a custom module
Below is what I have got so far but it does not fire in the workflow trigger.
I am not sure what I have to change but a little guidance would very much be appreciated



void automation.Convert_insurance_referral()
{
    try
    {
        leadId = Lead_ID;

        if(leadId == null)
        {
            info "Error: input.id is null.";
            return;
        }

        // get lead record
        lead = zoho.crm.getRecordById("Leads", leadId);

        if(lead == null || lead.isEmpty())
        {
            info "Error: No Lead found for ID: " + leadId;
            return;
        }

        // convert lead
        convertMap = map();
        convertMap.put("overwrite", true);

        converted = zoho.crm.convertLead(leadId, convertMap);

        if(converted == null || converted.isEmpty())
        {
            info "Error: Lead conversion returned no response for Lead ID: " + leadId;
            return;
        }

        contactId = converted.get("Contacts");

        if(contactId == null)
        {
            info "Error: Lead was converted, but no Contact ID was returned. Response: " + converted.toString();
            return;
        }

        // create Initial Assessment record
        assessmentMap = map();

        contactLookup = map();
        contactLookup.put("id", contactId);

assessmentMap.put("Contact", contactId);
        assessmentMap.put("Contact", contactLookup);
        assessmentMap.put("Insurance_Provider", lead.get("Insurance_Provider"));
        assessmentMap.put("Case_ID", lead.get("Case_ID"));
        assessmentMap.put("Case_Handler", lead.get("Case_Handler"));
        assessmentMap.put("Approved_Treatments", lead.get("Approved_Treatments"));
        assessmentMap.put("Venue", lead.get("Venue"));
        assessmentMap.put("Assessment_Date", lead.get("Assessment_Date"));
        assessmentMap.put("Assessment_Status", lead.get("Assessment_Status"));
        assessmentMap.put("Assigned_Therapist", lead.get("Assigned_Therapist"));

        // mandatory field
        assignedTherapist = lead.get("Assigned_Therapist");
        if(assignedTherapist != null)
        {
            assessmentMap.put("Record_Name", assigned_Therapist);
        }
        else
        {
            assessmentMap.put("Record_Name", "Assessment for Contact " + contactId);
        }

        createResp = zoho.crm.createRecord("Initial_Assessments", assessmentMap);

        if(createResp == null || createResp.isEmpty())
        {
            info "Error: Initial_Assessments record creation returned no response.";
            return;
        }

        if(createResp.get("id") != null)
        {
            info "Success: Initial Assessment created. Record ID: " + createResp.get("id");
        }
        else
        {
            info "Warning: Record creation response did not include an ID. Response: " + createResp.toString();
        }
    }
    catch (e)
    {
        info "Exception occurred in Convert_insurance_referral: " + e.toString();
    }
}

    Access your files securely from anywhere

          Zoho FSM Video Tutorials


                All-in-one knowledge management and training platform for your employees and customers.






                                      Zoho Developer Community




                                                            • Desk Community Learning Series


                                                            • Digest


                                                            • Functions


                                                            • Meetups


                                                            • Kbase


                                                            • Resources


                                                            • Glossary


                                                            • Desk Marketplace


                                                            • MVP Corner


                                                            • Word of the Day


                                                            • Ask the Experts



                                                                      • Sticky Posts

                                                                      • Function #46: Auto-Calculate Sales Margin on a Quote

                                                                        Welcome back everyone! Last week's function was about displaying the discount amount in words. This week, it's going to be about automatically calculating the sales margin for a particular quote, sales order or an invoice. Business scenario Where there is sales, there's also evaluation and competition between sales reps. A healthy rivalry helps to better motivate your employees to do smart work and close deals faster and more efficiently. But how does a sales rep get evaluated? 90% of the time, it's
                                                                      • Zoho CRM Functions 53: Automatically name your Deals during lead conversion.

                                                                        Welcome back everyone! Last week's function was about automatically updating the recent Event date in the Accounts module. This week, it's going to be about automatically giving a custom Deal name whenever a lead is converted. Business scenario Deals are the most important records in CRM. After successful prospecting, the sales cycle is followed by deal creation, follow-up, and its subsequent closure. Being a critical function of your sales cycle, it's good to follow certain best practices. One such
                                                                      • User Tips: Auto-Create Opportunity/Deal upon Quote Save (PART 1)

                                                                        Problem: We use quotes which convert to sales orders but Users / Sales Reps do not create opportunities / deals and go straight to creating a quote. This leads to poor reporting. Implementing this solution improves reporting and makes it easier for users.
                                                                      • Custom Function : Automatically send the Quote to the related contact

                                                                        Scenario: Automatically send the Quote to the related contact.  We create Quotes for customers regularly and when we want to send the quote to the customer, we have to send it manually. We can automate this, using Custom Functions. Based on a criteria, you can trigger a workflow rule and the custom function associated to the rule and automatically send the quote to customer through an email. Please note that the quote will be sent as an inline email content and not as a PDF attachment. Please follow
                                                                      • Function #50: Schedule Calls to records

                                                                        Welcome back everyone! Last week's function was about changing ownership of multiple records concurrently. This week, it's going to be about scheduling calls for records in various modules. Business scenario Calls are an integral part of most sales routines.. Sales, Management, Support, all the branches of the business structure would work in cohesion only through calls. You could say they are akin to engine oil, which is required by the engine to make all of it's components function perfectly. CRM


                                                                      Manage your brands on social media



                                                                            Zoho TeamInbox Resources



                                                                                Zoho CRM Plus Resources

                                                                                  Zoho Books Resources


                                                                                    Zoho Billing 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


                                                                                                                ご検討中の方





                                                                                                                          • Recent Topics

                                                                                                                          • Export Exchange Online Archive Mailboxes to PST for Microsft 365 Users

                                                                                                                            With Microsoft 365 it is possible to archive older emails in Exchange Online in order to keep the main mailbox tidy. If however you need to export the archived emails to a PST file for the purposes of backup, migration, compliance or for use offline,
                                                                                                                          • Lookups and Custom Modules

                                                                                                                            I created a Custom Module that I'm calling "Item Purchasing Group". This module will store information for groups of Items that must be purchased together (including minimum overall quantities and/or values, etc.). This will have a one-to-many relationship
                                                                                                                          • Task Module quick create settings

                                                                                                                            Hello, requesting the Task module receive a quick create customization settings. We have added custom fields and have to select "More fields" at the bottom of the pop-up to access the custom fields.
                                                                                                                          • Your employees changed departments. Did your IT systems notice?

                                                                                                                            An employee joins your Marketing team. HR adds their details to the organization's user directory. The IT admin, in turn, creates their Zoho One account, assigns the required applications, adds them to groups and provides access based on the organization's
                                                                                                                          • AI Calling

                                                                                                                            Hi, does anyone have experience or any thoughts on AI Calling. Getting AI to make calls on behalf of your company. We are looking into it, but are finding it difficult to get info and providers that can assist.
                                                                                                                          • Zoho Books | Product updates | August 2026

                                                                                                                            Hello users, July has been an exciting month for Zoho Books! This month, we're excited to introduce HTML PDF Templates, Placeholders as Pills, expanded approval workflows for Sales Returns and Journals, and significant compliance updates across the India,
                                                                                                                          • Button or Links order

                                                                                                                            Is there a way to re-order the buttons or links that are created? Moderation Update: With our recent enhancement to custom button creation from the layout editor, administrators can now reorder custom buttons directly from the layout editor, and this
                                                                                                                          • Email Forwarding to Zoho Desk Failing After Migration from Gmail to Outlook (Microsoft)

                                                                                                                            We recently migrated from Gmail to Microsoft Outlook. Since the migration date, emails sent by our customers are no longer being received by Zoho Desk. I tried setting up the email forwarding rules in Outlook similar to what we had in Gmail, but it still
                                                                                                                          • Option to Disable Knowledge Base Section in Feedback Widget Popup Hello Zoho Desk Team

                                                                                                                            Hello Zoho Desk Team, How are you? We are actively using Zoho Desk and would like to make more use of the Feedback Widget. One of the ways we implement it is through the popup option. At the moment, the popup always displays the Knowledge Base section,
                                                                                                                          • How to Fix an Outlook OST File That Cannot Be Opened

                                                                                                                            Have you at any time attempted to open Outlook only to find that your OST file cannot be accessed? It can be very annoying, particularly since the file holds important emails, attachments, and other mailbox data. This problem might arise due to file corruption,
                                                                                                                          • Record positive and negative bank transactions in the same expense account

                                                                                                                            Hello, I hosted a promotional event and paid a vendor $600 for food catering (bento boxes). Twenty people attended the event, and each person paid $30 for a bento box, resulting in 20 separate $30 transactions deposited into the bank. I coded the $600
                                                                                                                          • Widget Height were destroyed

                                                                                                                            All widget heights in the Details Canvas view are broken. Moderation Update: This is a known issue with widget heights in Client Script popups and flyouts. A fix is in progress, and this post will be updated once it's released.
                                                                                                                          • Address limits per customer by edition

                                                                                                                            I’m on the Standard edition and have reached a limit of 30 addresses under a single customer. Before I move to an annual Professional subscription, I need to confirm the following: What is the maximum number of addresses allowed under one contact, and
                                                                                                                          • Is it possible to log text messages from iphone into Zoho CRM

                                                                                                                            My team is more and more utilizing text messaging to communicate with clients. Does Zoho have a solution for logging these text messages when clicking "Send Text Message" from the Zoho app. Much like when you call, you get prompted to log a call, can
                                                                                                                          • CRM Address Field - States with Countries in brackets

                                                                                                                            Hi, Could you please remove the country in brackets from the Global State List, or at least allow us to edit these entries? It looks like the brackets were added during the initial data population, perhaps by someone building the list in a spreadsheet
                                                                                                                          • 👍 Zoho CRM's Notes now gets Reactions and a new look

                                                                                                                            Available in SA and JP DCs. Rolling out to other DCs in phases. Hello everyone, Notes help users capture important updates, collaborate with teammates, and maintain context for records. Now with Note Reactions, users can quickly acknowledge updates, express
                                                                                                                          • Meet PageHealth by Zoho PageSense: a free way to find out what's holding your page back

                                                                                                                            We all know the feeling. You've spent days tweaking headlines, moving buttons, and rewriting copy, and you're still not sure why visitors aren't sticking around. Revamping your website is hard, and figuring out what's actually getting in the way is even
                                                                                                                          • How can I show an uploaded image larger/full size in a Zoho Forms response PDF?

                                                                                                                            Hi,  I noticed that in a response PDF for Forms, the uploaded image is shown in a tiny box as seen in my screenshot. Is there any way I can make that appear larger in the response PDF? thanks.
                                                                                                                          • Convert MSG to PDF in Bulk with Attachment Free

                                                                                                                            Microsoft Outlook saves each email as an MSG file, keeping with it key information like the sender, the recipient, the subject, the date, the body of the message, and any attachments. It can, however, be quite difficult to access a large number of MSG
                                                                                                                          • Zoho Tables is now part of Zoho One!

                                                                                                                            Hey everyone! We've got some exciting news to share. Zoho Tables is now included in your Zoho One subscription at no extra cost. If you're already on Zoho One, head to your app list, add Zoho Tables, and get started right away. You don't need a separate
                                                                                                                          • How to mass find and delete duplicate files from OneDrive

                                                                                                                            It is easy to save documents, photos, videos, and all other types of files using Onedrive, but if you upload the same files more than once then your OneDrive storage can end up being filled with a large number of duplicate files. Manually searching out
                                                                                                                          • Different Report sharing filters within same Dashboard

                                                                                                                            I have a question about sharing filters for a dashboard which contains separate reports built from the same query. Below are the pieces of the puzzle: - “Sales Query”: line-level query containing sales for a team of 5 sales reps; there’s no need for the
                                                                                                                          • Specifying time increments on a Date/Time field

                                                                                                                            Hi all, Im using a Date/Time field in my CRM module. At the moment the increments are 30 minutes. How can I change these to be 15 minutes? Thanks
                                                                                                                          • not able to convert pdf to jpg and other forms and vice versa.

                                                                                                                            i want to change my pdf to jpg, word, etc and some times jpg to pdf. i don't know how to do in this.
                                                                                                                          • Make Your Workflows Smarter with Zia Agents

                                                                                                                            Hello, Enterprise Support Community, Workflow rules can now go beyond predefined actions. Zia Agents can now be invoked directly from workflow rules in Zoho CRM, allowing you to bring contextual, AI powered actions into your automated processes. Choose
                                                                                                                          • How can I add a Custom Field (or Customer_name) to a picklist?

                                                                                                                            Our workflow is Shopify-->SO -->Picklist-->Package-->Shipment. We would like to have the Picklist template to include a custom field "Customer_Notes" (we have created this field already). This way we get alerted when a customer has notes on their account.
                                                                                                                          • DYK 14: Create Tasks with AI

                                                                                                                            Did you know AI can suggest tasks within your Zoho Projects portal? Breaking a project into clear, actionable work items takes time and manual effort. Especially when the same team handles both planning and execution. AI task suggestions in Zoho Projects
                                                                                                                          • #11 Nithya's First Overseas Client

                                                                                                                            Nithya designs for clients in three countries and has never met any of them. Her first overseas invoice took a full evening. The second took four minutes. The difference was not a clever tax trick. She stopped treating every international customer as
                                                                                                                          • Other languages in Schedulers (Zoho Books)

                                                                                                                            Hello everyone, currently we have create functions in other languages, like nodejs etc but on schedulers we can use only deluge.. Are other languages on schedulers roll out? Kind regards, Sakis Oikonomou
                                                                                                                          • New in Office Integrator: Extract data from images into your spreadsheet

                                                                                                                            Hi users, We are pleased to introduce the Data from Picture feature in Zoho Office Integrator's spreadsheet editor. It intelligently detects and organizes text and numbers from any image into structured cells using OCR. With this feature, users can turn
                                                                                                                          • Edit PDFs using Zoho PDF Editor

                                                                                                                            Hello users, In a previous article, we covered the organizing capabilities of Zoho PDF Editor. Here, we'll provide a quick recap of its editing features, including a few new additions. A few highlights of Zoho PDF Editor's editing capabilities: Add and
                                                                                                                          • Announcing the new SKILL.md for Zoho CRM and the updated OAS repository!

                                                                                                                            We are introducing a new zoho-crm skill to make working with Zoho CRM Developer tools (like APIs, functions, widgets, client scripts, queries etc) easier and faster, with the help of AI in your preferred AI harness like Claude Code, Codex, Cursor, VSCode
                                                                                                                          • Partner with HDFC And Sbi Bank.

                                                                                                                            Hdfc and sbi both are very popular bank if zoho books become partner with this banks then many of the zoho books users will benefit premium features of partnered banks.
                                                                                                                          • Solution to Import OST File into Office 365.

                                                                                                                            In today’s digital workplace, organizations are rapidly moving toward cloud-based email systems for better flexibility, security, and collaboration. Microsoft 365 has become one of the most widely used platforms for business communication. A common requirement
                                                                                                                          • Multiple subscription plan line items in Zoho Billing quotes

                                                                                                                            I run an IT company and sell a lot of licences. A client might have multiple subscription plans including software licences in different categories. A client might have Microsoft licences, antivirus licences, web hosting and maintenance package services.
                                                                                                                          • Mail Merge templates in Sandbox

                                                                                                                            Rolled out for all DCs Hello everyone, You can now create and test Mail Merge templates directly in Sandbox, making it easier to validate document generation without affecting your live organization. Why this matters Mail Merge templates are often used
                                                                                                                          • Convert MBOX to PST File Using Free Methods

                                                                                                                            MBOX is a mailbox format that is used by various email clients and services, such as Thunderbird, Apple Mail, Eudora, and Google Takeout. Yet, in order to be able to open your MBOX emails in Microsoft Outlook, you have to convert them from MBOX to PST
                                                                                                                          • Zoho Books | Product updates | October 2026

                                                                                                                            Hello users, October brings a range of new features and enhancements to Zoho Books, designed to simplify compliance, streamline accounting workflows, and improve inventory management. From the launch of the Nigeria Edition and France’s e-invoicing capabilities
                                                                                                                          • Dashboard Table of “My New Work Orders” Changes View

                                                                                                                            Hi FSM Team, We noticed an inconsistency with the Dashboard Table of “My New Work Orders.” Initially, the table is configured to use the “My New Work Orders” view. When we go to the Home page, the table displays a different set of records. When we return
                                                                                                                          • Tips & Tricks #6 | Zoho Vault: Audita actividad, Gestiona accesos, Comparte credenciales & mucho más.

                                                                                                                            ¿Sabías que Zoho Vault puede hacer mucho más por la seguridad de tu equipo? Las contraseñas forman parte del día a día de cualquier persona y organización. Aplicaciones, herramientas internas, cuentas de clientes, servicios externos, plataformas de marketing,
                                                                                                                          • Next Page