issue with deluge script

issue with deluge script

i used chat gpt to build this script and I am getting 2 errors which I cannot figure out how to fix: 

void monthly_sales_order_generation()
{
    try
    {
        // ---------------- CONFIG -------------------

        salesorder_module = "SalesOrders";
        so_status_pending = "Pending Billing Review";

        // Products IDs
        prod_99492 = "5868377000023099069";
        prod_99493 = "5868377000023266001";
        prod_99494 = "5868377000023266006";
        prod_G2214 = "5868377000023266011";

        // Account CPT rate fields
        rateField_99492 = "field1";
        rateField_99493 = "field";
        rateField_99494 = "field2";
        rateField_G2214 = "G2214";

        // Analytics report columns
        visit_cpt_field = "CPT_Code";
        visit_date_field = "Visit_Date";
        account_field = "Account_ID";

        // ---------------- FETCH VISITS -------------------
        resp1 = invokeurl
        [
            url : analytics_url_1
            type : GET
            connection : "YOUR_ANALYTICS_CONNECTION"
        ];
        visits1 = resp1;

        resp2 = invokeurl
        [
            url : analytics_url_2
            type : GET
            connection : "YOUR_ANALYTICS_CONNECTION"
        ];
        visits2 = resp2;

        all_visits = list();
        all_visits.addAll(visits1);
        all_visits.addAll(visits2);

        // ---------------- DEFINE PREVIOUS MONTH -------------------
        todayDate = zoho.currentdate;
        first_of_this_month = todayDate.withDayOfMonth(1);
        prev_month_end = first_of_this_month.addDay(-1);
        prev_month_start = prev_month_end.withDayOfMonth(1);

        // ---------------- GROUP VISITS BY ACCOUNT -------------------
        grouped = map();

        for each v in all_visits
        {
            acc = v.get(account_field);
            cpt = v.get(visit_cpt_field);
            vdate_str = v.get(visit_date_field);

            if(acc != null && cpt != null && vdate_str != null)
            {
                vdate = vdate_str.toDate();
                if(vdate >= prev_month_start && vdate <= prev_month_end)
                {
                    if(!grouped.containsKey(acc))
                    {
                        grouped.put(acc, map());
                        grouped.get(acc).put("visitsList", list());
                    }

                    accMap = grouped.get(acc);
                    if(!accMap.containsKey(cpt))
                    {
                        accMap.put(cpt, list());
                    }

                    accMap.get(cpt).add(v);
                    accMap.get("visitsList").add(v);
                    grouped.put(acc, accMap);
                }
            }
        }

        // ---------------- CREATE SALES ORDERS -------------------
        for each accId in grouped.keys()
        {
            accAgg = grouped.get(accId);
            product_details = list();

            accResp = zoho.crm.getRecordById("Accounts", accId);
            if(accResp != null && accResp.size() > 0)
            {
                accRec = accResp;

                qty_99492 = accAgg.containsKey("99492") ? accAgg.get("99492").size() : 0;
                qty_99493 = accAgg.containsKey("99493") ? accAgg.get("99493").size() : 0;
                qty_99494 = accAgg.containsKey("99494") ? accAgg.get("99494").size() : 0;
                qty_G2214 = accAgg.containsKey("G2214") ? accAgg.get("G2214").size() : 0;

                price_99492 = accRec.get(rateField_99492) != null ? accRec.get(rateField_99492).toDecimal() : 0;
                price_99493 = accRec.get(rateField_99493) != null ? accRec.get(rateField_99493).toDecimal() : 0;
                price_99494 = accRec.get(rateField_99494) != null ? accRec.get(rateField_99494).toDecimal() : 0;
                price_G2214 = accRec.get(rateField_G2214) != null ? accRec.get(rateField_G2214).toDecimal() : 0;

                if(qty_99492 > 0)
                {
                    line = map();
                    line.put("product", {"id": prod_99492});
                    line.put("quantity", qty_99492);
                    line.put("list_price", price_99492);
                    line.put("CPT_Code", "99492");
                    product_details.add(line);
                }

                if(qty_99493 > 0)
                {
                    line = map();
                    line.put("product", {"id": prod_99493});
                    line.put("quantity", qty_99493);
                    line.put("list_price", price_99493);
                    line.put("CPT_Code", "99493");
                    product_details.add(line);
                }

                if(qty_99494 > 0)
                {
                    line = map();
                    line.put("product", {"id": prod_99494});
                    line.put("quantity", qty_99494);
                    line.put("list_price", price_99494);
                    line.put("CPT_Code", "99494");
                    product_details.add(line);
                }

                if(qty_G2214 > 0)
                {
                    line = map();
                    line.put("product", {"id": prod_G2214});
                    line.put("quantity", qty_G2214);
                    line.put("list_price", price_G2214);
                    line.put("CPT_Code", "G2214");
                    product_details.add(line);
                }

                if(product_details.size() > 0)
                {
                    soMap = map();
                    soMap.put("Account_Name", {"id": accId});
                    soMap.put("Subject", "Monthly CPT Billing - " + prev_month_start.toString("MMMM yyyy"));
                    soMap.put("Status", so_status_pending);
                    soMap.put("Product_Details", product_details);
                    soMap.put("Billing_Month", prev_month_start.toString("yyyy-MM-dd"));

                    createResp = zoho.crm.createRecord(salesorder_module, soMap);
                    if(createResp.get("id") != null)
                    {
                        info "Created Sales Order " + createResp.get("id") + " for Account " + accId;
                    }
                    else
                    {
                        info "Failed to create Sales Order for Account " + accId + ": " + createResp.toString();
                    }
                }
            }
        }
    }
    catch (e)
    {
        info e;
    }
}



 Syntax error. Expecting ';'. Found '.'. (Line : 73)
 Improper code format Correct format : <return_type> <category>.<function_name>(<type> <arg1>, <type> <arg1>,...<type> <arg50>){ <code> }

      • 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

        • Recent Topics

        • Prefill form with CRM/Campaigns

          I created a form in zForms and created prefill fields. I added this to the CRM and selected the fields so when sending from the CRM, the form works great. However, I want to use the same form in Campaigns and I want it to pull the data from CRM (which
        • Notes badge as a quick action in the list view

          Hello all, We are introducing the Notes badge in the list view of all modules as a quick action you can perform for each record, in addition to the existing Activity badge. With this enhancement, users will have quick visibility into the notes associated
        • Triggering a campaign automation from a Form

          I used Forms to create a lead form that is accessed by a button on my website. The field information flows into the CRM. However, I am trying to figure out how to use Campaign automations to start a workflow (series of campaign emails) that is triggered
        • Employee Appraisal Applicability - Why is Date of Joining Hard-Coded?

          In the new (to me, at least) Performance Appraisal Cycle wizard, it's possible to set criteria to determine for whom the appraisal process should apply. This makes sense on its face. However, one MUST use the Date of Joining criterion as a filter. Why
        • Formula fields

          Zoho People now supports formula fields. This post illustrates it. Formula fields are fields whose value is calculated instead of being entered by the user. Using this, number, decimal and date manipulations can be done. The value of this field could be numeric or date depending on the output of the formula. In date manipulations, the result will be given in milliseconds, which you can format as per you need. The operators we support are +, - , *, /. Formula fields get recalculated automatically
        • Copy paste from word document deletes random spaces

          Hello Dear Zoho Team, When copying from a word document into Notebook, often I face a problem of the program deleting random spaces between words, the document become terribly faulty, eventhough it is perfect in its original source document (and without
        • Is it possible to use module field filters via URL parameters?

          It would be really convenient if I could quickly link to a filter. For reference, this is the filter functionality I'm referring to: https://help.zoho.com/portal/en/kb/crm/customize-crm-account/advanced-filters/articles/advanced-filters For example: My
        • Support for Custom Fonts in Zoho Recruit Career Site and Candidate Portal

          Dear Zoho Recruit Team, I hope you're doing well. We would like to request the ability to use custom fonts in the Zoho Recruit Career Site and Candidate Portal. Currently only the default fonts (Roboto, Lato, and Montserrat) are available. While these
        • Lightbox Pop-up form

          I would like to embed my form using the lightbox pop up. I don't want it to load automatically. I want it to load when some clicks the button. I can see this option, however when I use the "show pop-up launch button" on the website, the button automatically
        • Unable to remove the “Automatically Assigned” territory from existing records

          Hello Zoho Community Team, We are currently using Territory Management in Zoho CRM and have encountered an issue with automatically assigned territories on Account records. Once any account is created the territory is assigned automatically, the Automatically
        • Data Processing Basis

          Hi, Is there a way to automate the data processing for a candidate every time an application arrives from job boards, without requiring manual intervention? That is, to automatically acquire consent for data processing. I've seen a workflow that allows
        • Lightbox Pop-up form

          I would like to embed my form using the lightbox pop up. I don't want it to load automatically. I want it to load when some clicks the button. I can see this option, however when I use the "show pop-up launch button" on the website, the button automatically
        • Zoho CRM for Everyone's NextGen UI Gets an Upgrade

          Hello Everyone We've made improvements to Zoho CRM for Everyone's Nextgen UI. These changes are the result of valuable feedback from you where we’ve focused on improving usability, providing wider screen space, and making navigation smoother so everything
        • Customer Management: #5 Never Let the Customer Slip

          When Rahul started Knight's Watch Consulting, his focus was simple: deliver good work and keep clients happy. He offered one-time consulting projects, monthly advisory retainers and usage-based support for growing clients. Business was steady, and customers
        • 10GB Email Storage Limits in Zoho CRM

          We’ve had Zoho One for almost 5 years and have always synced our emails from Gmail via IMAP… As of late, we’ve run into issues with our emails not syncing, due to being over the 10GB storage cap… What’s very odd is that we haven’t changed a thing? I know
        • Zoho Projects Android and iOS app update: Mobile device permission based on user profiles

          Hello everyone! We have brought in support for mobile device permissions based on the user profiles which are configured in organization level. Administrators can now configure the permissions on the web app(projects.zoho.com) by following the steps mentioned
        • Good news! Calendar in Zoho CRM gets a face lift

          Dear Customers, We are delighted to unveil the revamped calendar UI in Zoho CRM. With a complete visual overhaul aligned with CRM for Everyone, the calendar now offers a more intuitive and flexible scheduling experience. What’s new? Distinguish activities
        • How to import data from PDF into Zoho Sheet

          I am looking to import Consolidated Account Statement (https://www.camsonline.com/Investors/Statements/Consolidated-Account-Statement) into zoho sheet. Any help is appreciated. The pdf is received as attachment in the email, this document is password
        • Multi-currency and Products

          One of the main reasons I have gone down the Zoho route is because I need multi-currency support.  However, I find that products can only be priced in the home currency, We sell to the US and UK.  However, we maintain different price lists for each. 
        • Unlocking New Levels: Zoho Payroll's Journey in 2025

          Every year brings its own set of challenges and opportunities to rethink how payroll works across regions, regulations, and teams. In 2025, Zoho Payroll continued to evolve with one clear focus: giving businesses more flexibility, clarity, and control
        • Zoho Projects Android and iOS app update: Timesheet module is now renamed as 'Time Logs', delete option has been renamed to 'Trash'.

          Hello everyone! We have now renamed the Timesheet module as Time Logs and the delete option as 'Trash' on the Zoho Projects Android and iOS app. Time Logs Android: Time Logs iOS: Trash option Android: Trash option iOS: Please update the app to the latest
        • Zoho Mail app update: Manage profile picture, Chinese (Traditional) language support

          Hello everyone! In the latest version (v3.1.9) of the Zoho Mail app update, we have brought in support to manage profile picture. You can now set/ modify the profile picture within the app. To add a new profile picture, please follow the below steps:
        • Reminders for Article Approval

          Is there a way to send reminders for approvers to review articles and approve/deny them? I'm not seeing that option anywhere.
        • To print Multiple delivery notes in batches

          In Zoho Books, we can print a Delivery Note from an Invoice using the Print Delivery Note option, but it is non-editable and always prints all line items from the invoice. Our requirement is to deliver invoiced items in batches and print delivery notes
        • Add Full-Screen Viewing for Quartz Recordings in the Client Interface

          Hi Zoho Team, We would like to request an enhancement to the Zoho Quartz client interface when viewing submitted recordings. Current Limitation: When viewing a Quartz recording from the client (user) interface, there is currently no option to switch the
        • 2025 Recap: A Year to Remember | Zoho Inventory

        • Important Update : Pipedrive deprecated fields no longer supported in Zoho Analytics

          Dear Pipedrive users, We would like to inform you about a recent update related to your Pipedrive integration with Zoho Analytics. The Pipedrive team has deprecated certain fields from their application. You can find more details in the official Pipedrive
        • Product Updates in Zoho Workplace applications | November 2025

          Hello Workplace Community, Let’s take a look at the new features and enhancements that went live across all Workplace applications this November. Zoho Mail Format comments easily using Slash Commands With Slash commands, you can easily format text, insert
        • Right-Click Pipeline to Open in New Tab

          Please add the ability to right-click on a pipeline to open it in a new tab
        • Adjusting Physical Inventory

          Not getting very far with support on this one, they say they are going to fix it but nothings happened since November. Please give this a thumbs up if you would like to see this feature or comment if you have some insight. Use Case: Inventory set to be
        • Power up your Kiosk Studio with Real-Time Data Capture, Client Scripts & More!

          Hello Everyone, We’re thrilled to announce a powerful set of enhancements to Kiosk Studio in Zoho CRM. These new updates give you more flexibility, faster record handling, and real-time data capture, making your Kiosk flows smarter and more efficient
        • How to install Widget in inventory module

          Hi, I am trying to install a app into Sales Order Module related list, however there is no button allow me to do that. May I ask how to install widget to inventory module related list?
        • Deluge date time issue

          The deluge function info zoho.currentdate.toString("MMM/YYYY") returns Dec 2026 instead of 2025
        • Sending automated messages that appear in the ticket's conversation thread

          Good morning, esteemed Zoho Desk community, warm greetings Today I am here to raise the following problem, seeking a solution that I can implement: I need to implement an automation that allows me to send reminder messages to customers when I am waiting
        • Issue with Zoho Creator Form Full-Screen View in CRM Related List Integration

          Hi Team, We have created a custom application in Zoho Creator and integrated it into Zoho CRM as a related list under the Vendor module, which we have renamed as Consignors. Within the Creator application, there is a form named “Pickup Request.” Inside
        • Set connection link name from variable in invokeurl

          Hi, guys. How to set in parameter "connection" a variable, instead of a string. connectionLinkName = manager.get('connectionLinkName').toString(); response = invokeurl [ url :"https://www.googleapis.com/calendar/v3/freeBusy" type :POST parameters:requestParams.toString()
        • sync views to sheet

          Im looking to sync my views aka reports in analytics to zoho sheets, when data is updated in analytics it also should be updated in sheets, till now zoho sheets only offer raw data connection and it is not enough as these reports are difficult to re-do
        • How to update the Status in a custom module?

          Hi, I have a custom module "cm_payment_registry" in Billing, I am trying to change the status which is "Draft" with: array = {"custom_status":"Approved"}; zoho.billing.update("cm_payment_registry",organization.get("organization_id"), XXXXXXXXXXXXXX, array,"connectionname");
        • is it possible to add more than one Whatsapp Phone Number to be integrated to Zoho CRM?

          so I have successfully added one Whatsapp number like this from this User Interface it seems I can't add a new Whatsapp Number. I need to add a new Whatsapp Number so I can control the lead assignment if a chat sent to Whatsapp Phone Number 1 then assign
        • Replace Zoho Invoice with QuickBooks

          We are implementing Zoho FSM for a cleaning business in the US with 50+ field workers. This business has been using Quickbooks for accounting for decades and will not migrate to Zoho Books. A major issue in the integration is the US sales tax calculation.
        • Next Page