Setting up the initial variable

Setting up the initial variable

I am trying to set up a script to copy the contents of certain fields from the contact module to the deals module (renamed to Proposed Systems).  I keep getting an error about thee variable declaration on line 2?  What am I missing?

Error:  "Failed to save the function
  • Variable 'proposed_system_id' is not defined Line Number: 2"
Script:

// Use the input variable for the Proposed System ID
proposed_system_id = proposed_system_id;  // The variable set manually

// Fetch the Proposed System record using the ID provided by the workflow
proposed_system = zoho.crm.getRecordById("Proposed_Systems", proposed_system_id.toLong());

if(proposed_system != null)
{
    // Get the contact ID from the Proposed System's "Contact_Name" lookup field
    contact_id = proposed_system.get("Contact_Name");  // Replace "Contact_Name" with the actual API name of your lookup field in Proposed Systems

    // Check if the Proposed System has an associated Contact
    if(contact_id != null)
    {
        // Fetch Contact details using the contact ID
        contact_info = zoho.crm.getRecordById("Contacts", contact_id.toLong());

        if(contact_info != null)
        {
            // Fetch all Proposed Systems associated with this contact
            proposed_systems = zoho.crm.searchRecords("Proposed_Systems", "(Contact_Name:equals:" + contact_id + ")");

            if(proposed_systems.size() > 0)
            {
                for each proposed_system_record in proposed_systems
                {
                    // Map the contact fields to the Proposed System fields
                    proposed_system_map = Map();
                    proposed_system_map.put("Email", contact_info.get("Email"));
                    proposed_system_map.put("Phone", contact_info.get("Phone"));
                    proposed_system_map.put("Mailing_City", contact_info.get("Mailing_City"));  // Replace with your actual field names

                    // Update each Proposed System with the contact information
                    update_proposed_system = zoho.crm.updateRecord("Proposed_Systems", proposed_system_record.get("id").toLong(), proposed_system_map);

                    // Check if the update was successful
                    if(update_proposed_system.get("status") == "success")
                    {
                        info "Proposed System " + proposed_system_record.get("id") + " updated successfully with Contact information";
                    }
                    else
                    {
                        info "Failed to update Proposed System " + proposed_system_record.get("id");
                    }
                }
            }
            else
            {
                info "No Proposed Systems found for this contact.";
            }
        }
        else
        {
            info "Contact not found.";
        }
    }
    else
    {
        info "No contact associated with this Proposed System.";
    }
}
else
{
    info "Proposed System not found.";
}

    Access your files securely from anywhere

          Zoho Developer Community




                                    Zoho Desk Resources

                                    • Desk Community Learning Series


                                    • Digest


                                    • Functions


                                    • Meetups


                                    • Kbase


                                    • Resources


                                    • Glossary


                                    • Desk Marketplace


                                    • MVP Corner


                                    • Word of the Day



                                        Zoho Marketing Automation
                                                • Sticky Posts

                                                • 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
                                                • 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
                                                • Function #37: Create a Purchase Order from a Quote

                                                  Welcome back everyone! Last week, we learnt how to calculate the total number of activities for a lead and further take note of the activity count for particular dates. For instance, from the period of Demo to Negotiation. This week, let's look at a function that lets you create a Purchase Order instantly from a Quote. Business scenario: In any form of business, one of the most important things to do is to document the transactions. Naturally, negotiation, signing an agreement, placing an order,
                                                • Function-2: Round-Robin assignment of records

                                                  Welcome back folks! Last week, we saw how to update sales commission in quotes using a custom function. This week, let's see an interesting use case asked by many of you - auto-assignment records by round-robin method. Business scenario: Right now, the solution allows you to auto-assign leads from web form and imported lists. Let us look at a need where you want to auto-assign leads from in-bound calls in a round-robin method, across modules. Prerequisite: You must create a permanent record in the


                                                Manage your brands on social media



                                                      Zoho TeamInbox Resources

                                                        Zoho DataPrep Resources



                                                          Zoho CRM Plus Resources

                                                            Zoho Books Resources


                                                              Zoho Subscriptions Resources

                                                                Zoho Projects Resources


                                                                  Zoho Sprints Resources


                                                                    Qntrl Resources


                                                                      Zoho Creator Resources



                                                                          Zoho Campaigns 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 Writer

                                                                                    Get Started. Write Away!

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

                                                                                      Zoho CRM コンテンツ






                                                                                        Nederlandse Hulpbronnen


                                                                                            ご検討中の方





                                                                                                  • Recent Topics

                                                                                                  • Option to specify or disable "Idle" times in preferences

                                                                                                    It seems strange to me that my Cliq shows me as "Idle" when I'm using the PC and available just because I haven't interacted with Cliq in a while.  I'm far from "Idle" so we're just treating "Idle" and "Available" to mean the same thing.  I'd like to suggest a setting to change the timeout or even disable the automatic "Idle" mode.
                                                                                                  • Link project tasks to tasks in CRM and/or other modules.

                                                                                                    Hello, I have created and configured a project in Zoho Projects with a set of tasks. I would now like to link these tasks (I imagine according to the ID of each one) to actions in the CRM: meetings, tasks, analytics). The aim is to link project tasks
                                                                                                  • Function #61: Automatically add free item to the invoice based on item quantity

                                                                                                    Hello everyone, and welcome back to another Custom Function Friday! During holiday seasons or special promotions, businesses offer deals like BOGO (Buy One, Get One), Buy 3 Get 1 Free, Buy 2 at 50% off, and much more to attract customers. These promotions
                                                                                                  • Regarding GST Report Issue in Zoho Books

                                                                                                    Hi, Right now, the very important point from my end is this Zoho Books issue. Here, you can see that we have created the invoice with the items of account sales and expenses. The journal is also correct. The profit and Loss statement is also correct.
                                                                                                  • Multiple Salesperson against an invoice

                                                                                                    Hello, Against a particular invoice, we have multiple sales people working. The reason we combine the invoice is becuase we are an exporter and often consolidate cargo for our customer to save them freight costs. How do I capture the contribution of each
                                                                                                  • Projectwise budget ---

                                                                                                    Can we have a Project wise subject in addition to the Monthly, and quarterly ACCOUNT LEVEL budget?
                                                                                                  • UI Arabic

                                                                                                    can i change the member portal UI to arabic in zoho community?
                                                                                                  • Looking back at Zoho Social's 2024: Highlights and memories

                                                                                                    Hey everyone, We hope you had a relaxing and joyous holiday season. Whether you're planning for the new year or still soaking in the magic of the season, we're here to share some exciting highlights from 2024 – a year that was fully packed with updates
                                                                                                  • BIN Locations

                                                                                                    Hi, I’m new to Zoho inventory and unless Im missing something, I cannot find BIN locations anywhere in ‘items’? please tell me it’s there somewhere?!? Thanks
                                                                                                  • Building a Zoho Extension for Webex CC - Handling URL Changes

                                                                                                    Hi everyone, I’m building a Zoho extension for Webex Contact Center (Webex CC) and facing an issue with handling URL changes. In telephony, I’ve set the URL of Webex CC to: https://desktop.wxcc-us1.cisco.com/ When this URL remains the same, everything
                                                                                                  • Remove County field from Customer Address input screen (or allow input to be deleted)

                                                                                                    We are in the USA and have just noticed that there is now a County field in the Customer Address input screen (and maybe other areas of Zoho Books, but this is the one affecting us at the moment). County is not important to our business, and in fact we
                                                                                                  • Bigin API Token Request ("invalid_client")

                                                                                                    Hi people, I tried to connect to the API without success, I've read all of the documentation multiple time and tried just about everything. I tried to do it with Python Request module and with Postman, passing the information through both the URL parameter
                                                                                                  • How to add a Data Updated As Of: dynamically in text?

                                                                                                    I need to add a "Data Updated As Of" in the dashboard to show when was the last date the data was updated. I tried to create a widget but it does not look really good, see below. Is there a way I can do this through the text widget and update it automatically
                                                                                                  • Shared Dashboard / Report Permissions : Read not Write

                                                                                                    hi all, We are missing a huge fonctionnalite in setting up Dashboards (and reports) on corporate level.  Currently, we can not set Read Permissions on share Dashboards (and reports) without giving write access as well When we create a corporate dashboard
                                                                                                  • Trying to catch error with ZOHO.CRM.HTTP.get (Response Code)

                                                                                                    Hello, I'm trying to get response header from ZOHO.CRM.HTTP.get, in order to catch error like 404 or something else but it seems that ZOHO.CRM.HTTP.get() method only returns the body of the response, and I see no way to access the headers returned. Is
                                                                                                  • Profile stitching with Zoho Marketing Automation

                                                                                                    When it comes to marketing, knowing who your audience is and tracking their interactions is vital. That's why Zoho Marketing Automation has taken a significant leap forward with its enhanced profile stitching feature. With this update, you can track your
                                                                                                  • GDPR

                                                                                                    Hi , I'm checking out the HIPPA capabilities and at the moment I can see only three modules that can be selected to enable HIPPA Any idea how I can add additional modules such as customers? TNX David
                                                                                                  • default task list for new project

                                                                                                    Is there any way to have a default task list already created in a project, when the project is created in Zoho Books?
                                                                                                  • Record less quantity than ordered in ZOHO inventory

                                                                                                    Lets say I ordered 100 widgets from a Vendor. I have paid the Vendor month ago and just waiting for the product to ship. I have finally received the products but have only received 80 widgets. I see no way in ZOHO to only receive 80 widgets. ZOHO is forcing
                                                                                                  • Stripe payments via Books invoice link missing email - affects fraud detection

                                                                                                    Hi, All our payments done via Books invoice link have a warning: Integration improvement available This transaction is missing customer email address, which affects fraud detection. Why doesn't Books pass this info to zohosecurepay.eu/books/... for more
                                                                                                  • Power of Automation: Automatically sync custom field data between two tasks.

                                                                                                    Hello Everyone, A Custom Function is a user-written set of code to achieve a specific requirement. Set the required conditions needed as to when to trigger using the Workflow rules (be it Tasks / Project) and associate the custom function to it. Requirement:-
                                                                                                  • 'View Invoice' button hyperlink taking to Google Business Maps listing

                                                                                                    The green "view invoice" button in my invoice emails is sending people to my Google maps business listing rather than the invoice. Both my clients and I are experiencing this as a new issue.
                                                                                                  • Introducing Record Summary: smarter insights at your fingertips

                                                                                                    Hello everyone, Building on the recent launch of Zoho's in-house Zia Large Language Model (Zia LLM)—a major milestone in Zoho CRM’s AI capabilities—we’re excited to introduce the Record Summary feature. This powerful addition makes use of Zia LLM to simplify
                                                                                                  • Quickbooks conversion and Internet sales

                                                                                                    Hello, we are considering converting from Quickbooks enterprise to Zoho Books and using MonotorZ for our mrp needs. Today we import Internet sales under a single customer with multiple ship to addresses. We want to maintain the detail in CRM for marketing
                                                                                                  • Migrating Zoho emails to Google Workspace

                                                                                                    Hi Is there a tool to migrate Zoho email to Google workspace?
                                                                                                  • Custom Functions - Calculate Commission - failure after migration from US to EU

                                                                                                    Hello, i would ask for help. My Custom Function - Calculate Commission stopped working and shows a failure. Mismatch of data type expression. Expected List but found String What is the problem? Could anyone help? Here is script: void automation.ObliczProwizje(Int
                                                                                                  • GoCardless Mandate Sync Question

                                                                                                    Hello, When syncing our customer database with GoCardless, some customers aren't working despite both email addresses matching in Zoho Books and GoCardless. Also what do we do about customers where they are associated with multiple accounts as these aren't
                                                                                                  • Create a draft in reply to an email via Emails API

                                                                                                    Hi, I’d like to use the outgoing webhook to automatically create a draft reply to incoming mail. How can I use the Emails API to create a draft reply that is linked to an existing email thread? I couldn’t find the relevant method in the documentation.
                                                                                                  • Weekly Tips: Flags for an organized mailbox

                                                                                                    Wishing you all a Happy New Year 🎉 As we step into 2025, it's time to refocus and set our intentions for the year straight. Whether you're already back at work or just returning from the holidays, you probably have emails that need your immediate attention,
                                                                                                  • Edit line item amount

                                                                                                    It would be sooooo much better to be able to edit the line item amount in all of the modules, if there is any variation in agreed prices it's extremely painful to calculate the rate to match ;-( The rate could be auto calculated on editing this field making life so much easier !
                                                                                                  • Chanel Partner

                                                                                                    Any Zoho channel partner or dubai based company who will help us for getting zoho services including the training for our staff
                                                                                                  • Refer a Friend Campaign

                                                                                                    I am looking to run a referral campaign that sees an initial email going to existing clients, asking them to refer a friend. For each new client referred, the existing client will get a ticket in a prize draw - the more new clients they refer, the more tickets they get in the draw.  I am wanting to figure out how this could be done via Zoho, and how these referrals can be tracked and linked to the existing client who referred them.
                                                                                                  • Emails cannot be received

                                                                                                    Hey, There is an issue in my Zoho account, E-mails can be send from my side but cannot be received on my account MX, DCIM and other are added but still cant receive them. Please help me to solve this problem at your earliest convenience and this is happening
                                                                                                  • How to Replace an Assessment in a Job Opening on Zoho Recruit

                                                                                                    Hi everyone, I’m currently using Zoho Recruit and would like to replace the assessment linked to a specific job opening. I want to remove the existing assessment and add a new one. What is the best way to do this without losing any important data or affecting
                                                                                                  • Newsletter in multiple languages

                                                                                                    Hi We are planning on starting to use Zoho Campaigns for our newsletters. Since we send our newsletters in three languages, I would need the "unsubscribe page" and other pages related to the NL (Thank you page and so on) to be available in different languages
                                                                                                  • i couldn't recall message as one of the receptionists didn't received the message and i want to recall it urgent

                                                                                                    i couldn't recall message as one of the receptionists didn't received the message and i want to recall it urgent as recall button doesn't appear
                                                                                                  • Servidores caidos?

                                                                                                    Buenas, Hoy 30/12/2024, mi empresa esta sufriendo bastante problemas para acceder a las aplicaciones de Zoho. No sabemos si es solo nuestra compañia o esta afectado a todos. Cuando intentamos acceder a las aplicaciones nos salta el siguiente error: A
                                                                                                  • How to get NSE/BSE Stock Prices in Zoho sheets?

                                                                                                    I've been looking for a function that provides me with the NSE/BSE listed stocks price in Zoho Sheets like GOOGLEFINANCE in Google sheets, but I found none. Please help if there is any way to het stock prices?
                                                                                                  • Tip #1- Remote support vs. unattended access: Contrasting two key concepts in tech assistance- 'Insider Insights'

                                                                                                    Hello everyone! We, at Zoho Community, are excited to introduce Insider Insights, a new series where we will look into various aspects of remote support technology and how they might help you. We'll be sharing tips, methods, and insights acquired from
                                                                                                  • Introducing Fair Evaluation for Interviews

                                                                                                    Collaboration is key in recruitment, but it’s important to ensure individual interviewers’ assessments are not influenced by others. With Fair Evaluation, you can choose how and when interviewers can see reviews of a candidate for the same job opening.
                                                                                                  • Next Page