Custom Button - IfElse Function

Custom Button - IfElse Function

We have a working custom function that can create PDFs from our module, in this instance we are using it to generate quotations from a lead module.

Button clicked > PDF created and attached to record

However, we operate in different countries and have different templates that change currency and date format.

So what I am trying to do is create an "IF ELSE" within the working function based on the selected currency of the lead.

E.g. If currency = USD excute this function A,  IF ELSE currency = GBP execute function B.
The intention to merge with the correct template based on currency.

Here is the function without currency if else.

templateid = "200903000003070203";
val = "Quotation for " + cname;
to_list = List();
from_map = Map();
to_map = Map();
mp = Map();
from_map.put("email",zoho.loginuserid);
from_map.put("user_name",zoho.loginuser);
to_map.put("email",email);
to_list.add(to_map);
mp.put("from_address",from_map);
mp.put("to_address",to_list);
mp.put("subject","Subject");
mp.put("content","Test Content");
mp.put("id",leadid);
mp.put("template_id",templateid);
// mp.put("attachment_name","Quotation for "+cname);
datalist = List();
datalist.add(mp);
datamap = Map();
datamap.put("data",datalist);
send = invokeurl
[
    url :"https://www.zohoapis.eu/crm/v2/Leads/actions/send_mail?type=mailmerge"
    type :POST
    parameters:datamap.tostring()
    connection:"zohocrm"
];
info "send:" + send;
file = invokeurl
[
    url :"https://zohoapis.eu/crm/v2/Leads/" + leadid + "/actions/print_preview?type=mailmerge&template_id=" + templateid + "&download_file_name=" + encodeUrl(val)
    type :GET
    connection:"zohocrm"
];
info file;
attach = zoho.crm.attachFile("Leads",leadid,file);
info attach;
return "Success! Refresh this page, PDF Proposal will appear in Attachments";


Additional considerations:

Macros and workflows will not work for this as you cannot trigger a macro from a custom button.
This feature MUST be controlled from a page view button, not a drop down menu.

    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



                                                            • 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
                                                            • 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
                                                            • 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,


                                                            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 Writer

                                                                                              Get Started. Write Away!

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

                                                                                                Zoho CRM コンテンツ




                                                                                                  Nederlandse Hulpbronnen


                                                                                                      ご検討中の方




                                                                                                            • Recent Topics

                                                                                                            • Associate email to deal and multiple contacts to deals

                                                                                                              Hi any news in how to associate emails to deal and to varios contacts in Bigin CRM? This feature would help in having deal and conversation all in one place so that when we open the deal or contact we have all the information in regard to deal that we
                                                                                                            • Chequered lines in notebooks

                                                                                                              Can the notebooks also be used with chequered lines or only with ruled lines? Or is it only available in blank? Thanks for the info! Greetings Andreas
                                                                                                            • How to add/remove tag to a ticket with function?

                                                                                                              Hi, I have had to create a function in Zoho Desk. However, it appears that the syntax differs from that in CRM. I realized that it is necessary to add organization ID in some commands what is not necessary when you create a funciotn in CRM. Could you
                                                                                                            • Introducing our latest privacy enhancement - Hiding email IDs in Zoho Cliq Networks

                                                                                                              Hello everyone, Zoho Cliq Networks offers a powerful collaboration platform that allows businesses to create dedicated digital workspaces for external vendors, partners, or individuals you want to communicate with professionally without adding them to
                                                                                                            • ERROR CODE554 5.1.8: unable to send message reason 554 5.1.8 email out going blocked

                                                                                                              Dear Zoho Mail Support, It's been nearly 24 hours and we still can't send emails. Our outgoing emails are blocked with the error message "554 5.1.8 Email Outgoing Blocked." This restriction is and will severely impact our business operations and causing
                                                                                                            • Zoho Desk Onboarding Assistance - How to do bulk taging

                                                                                                              Hi How to apply a particular tag to multiple tickets in one go.
                                                                                                            • New Assembly Screen - Doesn't Search by SKU

                                                                                                              When one wants to make an Assembly by clicking the plus sign from the "Assemblies" tab, the first step is to enter the Composite Item that one wishes to assemble. Logical, but the problem is that one cannot search that by SKU, only product name. This
                                                                                                            • CRM Client Script Buttons

                                                                                                              Hello,  Client Script ZDK list button functions, but I am not sure how to interact with them. I tried a few methods of getting the API name for a custom button, but no luck. Any ideas where the button API names are stored?  Also, custom buttons must be
                                                                                                            • Announcement - Custom Function Series

                                                                                                              Hi folks! One of the key attributes of Zoho Books that we're really proud of is the ability to automate your routine accounting tasks in an efficient manner. For most businesses, accounting would involve a set of repetitive tasks that consume a good chunk
                                                                                                            • Zoho CRM Create Client script using Custom Buttons

                                                                                                              Client script has become quite sophisticated and it's really useful. There is a missing simple functionality: To create script should be able to be called in the details page using a custom button. If we have this feature for Field Event, shouldn't we
                                                                                                            • Client Script event on any field of a Detail page

                                                                                                              Hi everyone! I'd like to trigger a Client Script when a user modifies a field - any field - from the Account Details page, how can I do this? I don't want to trigger it on a specific field, but on all of them. Thanks in advance!
                                                                                                            • Move Quote/Deals from a Contact to Another

                                                                                                              In our business contacts often move to different accounts, and it is simple to reassign the contact, but not so easy to move their quotes/deals to another contact at the account they are no longer with. Looking to see if there is a function to move quote/deals
                                                                                                            • Feature Request – Support for Saskatchewan PST Self-Assessment in Zoho Books

                                                                                                              I’d like to suggest a feature enhancement for Zoho Books regarding Saskatchewan PST (SK PST) self-assessment. Currently, when filing the SK PST return using Zoho Books’ return generator, there is a field labelled “Consumption Tax”, which is intended for
                                                                                                            • Connect and Engage On the Go: How Zoho SalesIQ's Mobile App Empowers Sales Teams?

                                                                                                              In sales, timing is crucial. It makes a huge difference. What if a prospect is checking out your pricing page? Or a high-value lead revisits your business' website or mobile app while you're at lunch? You can’t afford to miss that opportunity, and you
                                                                                                            • Any timeline for these features?

                                                                                                              Hello! Was wondering if there was a timeline to for the following features: Increased API Access for automations. The Rules are nice, but really need more automation, such as adding things to CRM, automating task creation, forwarding emails, etc. "negative"
                                                                                                            • Projects Timesheets integration with Quickbooks

                                                                                                              When will Zoho Projects Time-sheets be integrated with Quickbooks? This will make us move to Zoho for all business needs (except for Quickbooks)
                                                                                                            • Unable to send a message to a contact from Zoho CRM

                                                                                                              From menu Contacts I choose a contact, on the right vertical menu i have five different choices: Add a potential, Add an activity Add an event Add a call Send a message. All af them works exept "Send a message". If i click on it I don't get nothing, no
                                                                                                            • Customization in PDF templates for custom modules

                                                                                                              I'm facing some difficulties when it comes to the custom modules in zoho books: 1) Is there any way to get the item table field for my custom module? It doesn't show up in the dropdown when trying to add a new field. 2) I was trying to somehow get 1)
                                                                                                            • Formación: Workshop de Zoho CRM y Servicio al Cliente

                                                                                                              Tu oportunidad para transformar tu forma de trabajar con Zoho Zoholics 2025 está pensado para ti, que quieres llevar tu uso de Zoho al siguiente nivel y aprovechar al máximo tu subscripción. Una de las experiencias más potentes de la agenda de Zoholics
                                                                                                            • Sorting alphabetically a collection in a Lookup

                                                                                                              Hello, In a lookup that looks at other lookups (!?), I had to make the following script to limit the list appearing in that lookup : ListeDispo = Offre_de_produits[Quantite_offerte > 0]; input.Produits:ui.add(ListeDispo.Produit_OFFRE.getall()); Works
                                                                                                            • Edit response and integration

                                                                                                              We have a zoho form that our employee starts and submits, and then a day or two later, they "edit their response". I have the zoho form integrated with the Salesforce crm. I submitted a response and it made a new record in the proper module. But when
                                                                                                            • Zoho Developer Hangout (ZDH) – Episode 18 | Zoho CRM Client Script for Efficient Sales Process

                                                                                                              Hello everyone, A streamlined sales process isn’t just a nice-to-have—it’s the engine that powers lead generation, builds stronger customer relationships, and closes deals faster. But what if you could take your CRM beyond the basics to actually help
                                                                                                            • Mobile no already in use

                                                                                                              When trying to bring up my email on another Zoho account I get asked, as a security measure, to add a mobile number. I have added a number before, but I tried again only to be told that the "Mobile number already exists", but I cannot proceed further.
                                                                                                            • error in making eway bill

                                                                                                              at the time of generating eway always a pope appers to enter the valid state code as state is auto gnerated while creating new customer
                                                                                                            • Need Feature to automatically fetch the registered GSTN Address of the AP Vendors

                                                                                                              Hello Zoho Need Feature to automatically fetch the registered GSTN Address of the AP Vendors and update the Zohobooks Vendor profile automatically so as to avoid manual address updations. Please do the needful here Thanks
                                                                                                            • Plug Sample #13: Display CRM Products as Dynamic Carousels in Your Chatbot

                                                                                                              Hi everyone! We’re back with another simple yet powerful plug to level up your chatbot experience. With the SalesIQ-CRM integration, you already have the ability to create leads, contacts, and deals directly within your CRM from SalesIQ, and view complete
                                                                                                            • Weekly Tips: Don't Delete, Just Archive

                                                                                                              For a business that relies heavily on email for communication, a cluttered inbox can be quite challenging to manage. Some emails can take up significant space in your inbox, making it difficult to navigate to other important emails. While these emails
                                                                                                            • Problema de sincronización de zoho mail con cliente Outlook

                                                                                                              Estoy presentando retardos en recibir los correos de Zoho en mi cliente Outlook a veces tarda mas de 20 minutos a pesar de haber llegado a la web no llega al cliente de escritorio y muchas veces debo cerrar el cliente y volverlo abrir para que llegue
                                                                                                            • Issue Updating URL Field with WorkDrive Link

                                                                                                              Hello, I’m working on a form with a file upload field. After uploading a file to WorkDrive, I fetch the public file link and update a field in the form with it. Workflow: When using the single-line text field ("File_URL"), the link is updated correctly
                                                                                                            • Should I Set Up Subdomain for Email Sends?

                                                                                                              Hi there, our team just bought a dedicated IP for our email sends. We send more than 100k emails/month. Because we face deliverability issues and also because of the mass sends, we decided to get a dedicated IP. My question is, should we set up subdomains
                                                                                                            • Incoming Email Not Coming Through

                                                                                                              Hi Zoho Team, I’ve recently set up my domain-based email with Zoho and everything appears configured correctly. However, I’m currently unable to receive any incoming emails. Could you please assist me in checking the following: MX records are set properly
                                                                                                            • Blocked: Reason 554 5.1.8 email outgoing blocked

                                                                                                              Hello, we have an issue while sending e-mails; whole organization with about 150 users is blocked "Unable to send message reason 554 5.1.8 email outgoing blocked", our domain is "ancient.global" Please help.
                                                                                                            • Error remote server is misconfigured

                                                                                                              Recently migrated the server to a new one. Updated MX records, SPF and DKIM values. DNS Lookup shows updated values. Still the email is getting bounced with the error: 553 Relaying disallowed
                                                                                                            • want to remove www

                                                                                                              I am trying to create my account but it doesn't let me erase the WWW . I don't need it for my email
                                                                                                            • Changer le lieu d'hébergement zohomail

                                                                                                              Est-il possible de faire héberger mon compte ailleurs qu'aux USA ? Compte-tenu de la situation de ce pays, un hébergement en Europe ou en Inde serait plus sûr.
                                                                                                            • Migration from Asana

                                                                                                              I see a lot of migration options for Zoho Projects, but don't seem to see Asana. Is there no clear migration path without going manual or custom?
                                                                                                            • NO RECIBO MAILS

                                                                                                              Hace más de 10 días no puedo recibir mails en mi correo. Si puedo enviar correos. Pueden ayudarme? Saludos, Christian Zegarra
                                                                                                            • I am not able to check in and checkout in zoho people even location access allowed

                                                                                                              This issue i am facing in mackbook air m1, I allowed location in chrome browser and i also tried in safari but getting similar issue. Please have a look ASAP.
                                                                                                            • Unable to receive emails

                                                                                                              Hi I am unable to receive emails but I am able to send externally
                                                                                                            • How to show User Full Name, not record id in a User Filter in analytics

                                                                                                              Please see screen recording: https://workdrive.zohoexternal.com/external/21a9e0c39c4595c255a62791fdf3655d3df933114a8f1598bc852d0ff7e56ce3
                                                                                                            • Next Page