Hello,
I need help handling error messages returned to my client script from a function.
The scenario
I have setup a client script button which is available from each Deal.
This CS executes a crm function, which in turn creates an invoice based on the information in the Deal.
The client script checks the deal is at the correct stage and displays the amount to be invoiced, before proceeding to execute the function.
The problem
It all works perfectly well except for the error handling. I'm only testing for a 'response' from the function ( in the Client Script) before showing a success or error message, so even if the function returns null or undefined, it still says it has been successful.
What I tried
So, I wanted to pass something more useful to the client script, like the newly created invoice number or id but it just doesn't seem to be working. I have tried using variations of this approach:
var output = JSON.parse(response.details.output)
but get this error amongst others...
"undefined" is not valid JSON
What doesn't help matters is that I can't fully test the invoice creation process, even using a crm sandbox, because it will still create real invoices in Books, which I would rather avoid.
What are your thoughts on how to approach this? Below are the relevant parts of my code, in case it is useful to see.
CRM Function
- string standalone.createtradeinvoicesa(String orderId,String userId,String invType)
- {
- // earlier code creates invMap with invoice items
- // CREATE NEW INVOICE IN ZOHO BOOKS
- resp = zoho.books.createRecord("Invoices",orgId,invMap,"zbooksall");
- if(resp.get("code") == 0)
- {
- //for client script
- invoiceid = resp.get("invoice").get("id");
- invoiceinfo = zoho.books.getRecordsByID("invoices",orgId,invoiceid,"zbooksall");
- info "client-script-output=" + invoiceinfo;
- invoiceNum = resp.get("invoice").get("invoice_number");
- invoiceDate = today.toDate("dd/mm/yyyy");
- invoiceDate = invoiceDate.toString("dd/MM/yyyy");
- //user id and name for note
- else
- {
- returnMsg = "Error : an invoice has not been created in Zoho Books.";
- }
- return invoiceinfo;
- }
Client Script
- var functionName = "xxx";
- // get the order and user ID of this page
- var record_id = $Page.record_id;
- var user_id = $Crm.user.id;
- // get field values
- var stage_value = ZDK.Page.getField('Stage').getValue();
- var orderNo = ZDK.Page.getField('Deal_Name').getValue();
- // other checks go before this in the full script
- //If user clicks Proceed button
- if (isProceed) {
- // Message
- var successText = 'You will find your draft invoice in the Zoho Finance section below.';
- var errorText = 'There has been a problem, your invoice has not been created.';
- // show loader
- ZDK.Client.showLoader({ type: 'page', template: 'spinner', message: 'Creating Invoice...' });
- // call function in variable
- var response = ZDK.Apps.CRM.Functions.execute(functionName, { "orderId": record_id, "userId": user_id });
- ZDK.Client.hideLoader();
- // show sucess or error messages and execute function
- // response from function is the new invoice information, so in theory, the response should be null/undefined if the invoice wasn't created.
- if (response) {
- var sucessMessage = ZDK.Client.showAlert(successText, 'Invoice Created', 'Close');
- return response & successMessage & $Client.refresh();
- } else {
- errorMessage = ZDK.Client.showMessage(errorText, { type: 'error' });
- return errorMessage;
- }
- }
- //If user clicks Cancel button from invoice creation
- else {
- return false;
- }
Recent Topics
Approvals in Zoho Creator
Hi, This is Surya, in one of my creator application I have a form called job posting, and I created an approval process for that form. When a user submits that form the record directly adding to that form's report, even it is in the review for approval.
Introducing Rule-Based AI Coding Assistants for Zoho Finance Widgets
Hello customers, We’ve introduced rule-based AI coding assistants to speed up Zoho Finance widget development. You can try them out in Cursor AI and GitHub Copilot. This helps you build widgets quickly using simple prompts, while ensuring the generated
Marketing Tip #21: Create an About Us page
People don’t just buy products, they buy from brands they trust. An About Us page helps customers understand who you are, what you stand for, and why your business exists. It adds a human touch to your store and reassures shoppers that there’s a real
Zobot to handle single choice menu when dynamic list content is more than 10 items
Whatsapp supports maximum of only 10 items for its single choice menu. When we need to show a dynamic list with content more than 10, this could be challenging. We essentially need to add a next and previous buton here in order to make it functional.
Add the ability to Hide Pages in Page Rules
Hi, We have Field Rules to show and hide fields and we have page Rules, but we can't hide a page in Page Rules so it isn't completed before the previous page (And then have the Deny Rules to prevent submitting without both pages completed), we can only
Column letter from number
Hello, I am trying to select a cell and i have the column number. How do i do this or is there a way of getting the letter from the number? Thank you
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
Composite Product (kit) - Dynamic Pricing
I am setting up Composite Products for item kits that I sell. I also sell the items from the kit individually. Problem is when pricing changes on an individual part, the Composite Product price does not change meaning when the cost of item # 2 in the
View Answer Bot conversations?
We are trialing Zia and are experimenting with Answer Bot on our knowledge base. So far so good! Management asks me if it is possible to view Answer Bot conversations, the purpose being to look over its shoulder and confirm that it is working as des
Train Zia answer bot on only part of Knowledge Base?
We are trialing Zia answer bot and hope to use it on the knowledge base to help our users find the information they are looking for. I have found how to train Zia on the entirety of our knowledge base. But is there a way to train it on only certain categories
Smarter holiday planning with yearly-specific Holiday Lists
Hello everyone! Managing holidays and business hours is now easier and more efficient. Holiday Lists now support holidays that fall on different dates every year, while business hours now supports more than one holiday list. This helps businesses manage
Temporary Outage in Zoho Cliq Affecting US Users – July 23, 2025
We experienced a service disruption in Zoho Cliq that impacted core functionality for users in the US region. The issue occurred between Jul 23, 2025, 06:54:00 PM IST and 07:13:13 PM IST, lasting approximately 19 minutes. To restore service stability,
Zoho Writer for Proposals
Hi, one of the things we've struggled with since moving to Zoho ecosystem is our proposal software Qwilr does not integrate well. It surprises me Zoho doesn't have proposal software but given all the capabilities of Zoho Writer, I'm wonder if anyone is
How Do Mutliple Sales People Prospect in the "LEADS" module without calling the same leads?
We have 4 sales reps and the Leads module does not have real time intuitive knowlodge to make the sales rteps dont call the same people at the same time. How can we crate a fluent prospecting sytem where the salres reps can go out bound without calling
Possible to delete the "Big Deal Alert" in Zoho CRM?
Hi, Is it possible to delete the "Big Deal Alert" in Zoho CRM? My company has no need for it and I want to remove it to clean up my email templates list. Thank you.
CRM HAS BEEN SOOO SLOW For Days 05/15/25
I have fantastic Wifi speed and have zero issues with other websites, apps, or programs. It takes an excruciatingly amount of time to simply load a record, open an email, compose an email, draft a new template, etc. Am I in a subset/region of subscribers
How to Create a Fixed Sliding Time Window (D-45 to D-15) in Zoho Analytics ?
Hello, I would like to create a report in Zoho Analytics based on a sliding time window between D-45 and D-15, with a fixed snapshot of that specific period. The data displayed should strictly reflect activity recorded between D-45 and D-15 only, without
Wie veröffentliche ich ein PDF Datei?
Hallo! Wie veröffentliche ich PDF Datein ich habe ein PDF Datei und den sieht ihr im Upload ich möchte ihn veröffentlichen wie? Mit Freundlichen Grüßen, Herr Bahaa Addin Chkirid
How exactly does "Reply assistance" work in Zoho Desk? What context is sent to the LLM?
Hi, Im trying to better understand the technical behavior of the feature "Reply assistance" in Zoho Desk, and I couldn’t find detailed information in the current documentation. Specifically, I have questions about what data is actually being sent to the
How Does Knowledge Base Search and Article Recommendation Work?
Hello, I would like to understand how the Knowledge Base search engine works. Specifically, does it search based on: The article title only? The full article content? Both, the article and the content? Keywords? Tags? Also, how does the system determine
🚀 WorkDrive 6.0 (Phase 1): Empowering Teams with Content Intelligence, Automation, Accessibility, and Control
Hello, everyone! WorkDrive continues to evolve from a robust file management solution into an intelligent, secure, and connected content collaboration platform for modern businesses. Our goal remains unchanged: to simplify teamwork, strengthen data security,
Zoho Campaigns: An Outstanding Email Marketing Tool
Introducing Zoho Campaigns! A product designed by Zoho, the Zoho Campaigns is made to create, deliver, and manage integrated email campaigns that can help in boosting the sales of a company and its customer base. Zoho Campaigns is actually an email marketing
Zoho Creator Developer Console | Improved Distribution and Lifecycle Management for apps
Hello everyone, We're excited to introduce new enhancements now in the Zoho Creator Developer Console. These updates strengthen private app distribution through licensing controls and extend environment support across all installed apps, helping teams
Anchor Links in Dashboards
Hello, Our dashboards frequently have multiple sections that would be more easily skipped between using anchor links. Please consider adding an anchor link feature to the text widget? This could be done by adding an anchor link option to the text widget next to the "remove" option (see screenshot). The option would assign an ID to the <div> containing the text widget in the live dashboard. Then, the chosen ID could be linked using a traditional <a href="#link_id"> in the html section of the text
Sync images with Shopify/Cart
Hello, sync images with shopify or other cart, it cuts out the double work of having to upload to shopify/cart and zoho. Thanks
Allow selection of select inactive users in User data fields
Hello, We sometimes need to select a previous employee that has an inactive account in the User data field. For example, when doing database cleanup and indicating actions are done by a certain employee that weren't filled out when they were part of the
Is it Possible to Modify Standard Report Urls
Is there a way to permanently modify standard report Urls? Use case: Suppose I have a Products report. Showing list as timeline, calendar, or kanban doesn't make sense. Want to hide that from users by adding #Report:Products?zc_ShowAs=false&zc_Print=false
Assessment Answered - Automation (Related List)
Hello everyone, We have linked a candidate assessment to our job posting. When someone applies, they are required to answer all the assessment questions. However, some candidates submit their applications without completing the questions. In such cases,
Updation of Old Browsers Versions for Zoho CRM
We have upgraded the default browser version for CRM to facilitate features like widgets and scripts that are often implemented aside from advanced functionalities for various business requirements. The latest version is aimed to provide better performance
External User onboarding for zoho connect is not really intuitive.
So the external user is sent an invite, which has a button that directs them to login to zoho to view the invite, but if they don't have a zoho account, they cannot access that invite, which seems kinda silly, as there is not real way on for them to create
Having trouble fetching contents of Zoho Connect Feeds using the API, requesting alternative API documentation.
I'm trying to retrieve feed/post data from Zoho Connect using the API but facing challenges with the current documentation. What I've tried: OAuth authentication is working correctly (getting 200 OK responses) Tested multiple endpoints: /pulse/nativeapi/v2/feeds,
How to upload file to Connect using API?
Hi there. I looked at the API documentation and nowhere did it mention how to use the API method to upload a file even though it is mentioned that it is possible to be done so. Please help.
Select the task view on the board in the Zoho Connect iPhone app
Hello. How do I select the task view on the board in the Zoho Connect iPhone app? The Android app has this functionality.
The power of workflows in Zoho Marketing Automation - Video Webinar
In this Zoho Marketing Automation video webinar, our experts walk you through: Why you may want to create marketing workflows How to create marketing workflows Use Zoho CRM data and apply workflows to automate your marketing strategy How workflows can
Auto tagging
Some of the articles I enter into Notebook get there when I enter them in Raindrop.io and IFTTT copies the articles in Notebook. When this happens the notes are tagged but instead of useful one word tags with topic the tag pertains to the specific article
Zoho Sheet for Desktop
Does Zoho plans to develop a Desktop version of Sheet that installs on the computer like was done with Writer?
WebDAV support
I need WebDAV support so that I can upload/download (and modify) documents from my local file system. Is anything planned in his direction?
Constant refresh required in lots of Zoho tabs
"Hey Zoho, if you can sync my notification bell across 15 tabs using a BroadcastChannel, why can't you send a 'Data Refresh' signal the same way? We don't need a browser reload—we just need the data to sync without us clicking F5 like it's 1999." "PS:
What's New in Zoho Billing | January 2026
Excited about the latest enhancements in Zoho Billing? Our January updates bring an intelligent AI assistant, smarter subscription management, and improved tax compliance, saving you time and reducing manual work. Dive into the details below to see how
Cliq iOS can't see shared screen
Hello, I had this morning a video call with a colleague. She is using Cliq Desktop MacOS and wanted to share her screen with me. I'm on iPad. I noticed, while she shared her screen, I could only see her video, but not the shared screen... Does Cliq iOS is able to display shared screen, or is it somewhere else to be found ? Regards
Next Page