Error Code 4: Invalid value passed for JSONString

Error Code 4: Invalid value passed for JSONString

Okay, I want to start by saying I know I'm a terrible scripter, so sorry if this is a dumb mistake. I just can't figure it out, even with LLM help.

Here's my code:
  1. // --- Input Variables ---
  2. customer_id = salesorder.get("customer_id");
  3. so_id = salesorder.get("salesorder_id");
  4. org_id = organization.get("organization_id");
  5. so_lines = salesorder.get("line_items");

  6. // --- Build Retainer Body ---
  7. retainer_body = Map();
  8. retainer_body.put("customer_id", customer_id);

  9. // --- Handle Custom Fields (Correctly as a List) ---
  10. cf_list = list();
  11. so_cf = Map();
  12. so_cf.put("index", 1);
  13. so_cf.put("show_on_pdf", false);
  14. so_cf.put("value", so_id);
  15. so_cf.put("label", "Sales Order");
  16. cf_list.add(so_cf);
  17. retainer_body.put("custom_fields", cf_list);

  18. // --- Handle Line Items (Correctly as a List) ---
  19. line_list = list();
  20. for each line in so_lines
  21. {
  22. line_map = Map();
  23. line_map.put("description", line.get("group_name") + " " + line.get("description"));
  24. line_map.put("rate", line.get("item_total"));
  25. line_list.add(line_map);
  26. }
  27. retainer_body.put("line_items", line_list);
  28. info "Final payload being sent: " + retainer_body;

  29. // --- API Call with Correct Syntax ---
  30. retainer_invoice = invokeurl
  31. [
  32. url: "https://www.zohoapis.com/inventory/v1/retainerinvoices?organization_id="+org_id
  33. type: POST
  34. parameters: retainer_body
  35. connection: "zom"
  36. ];

  37. info retainer_invoice;

  38. // --- Return Success ---
  39. resultMap = Map();
  40. resultMap.put("message", "Retainer Invoice created from Sales Order: " + so_id);
  41. resultMap.put("code", 0);

Shockingly, I managed to do this almost entirely by myself. The only error that the LLM accurately caught was that my code for the custom field was not properly formatted as a list.

The error / log I'm getting is below:

I assume there's something wrong with the formatting of the retainer_invoice map being sent in the API call?

Here's the entirety of that map, as copied from the log:
  1. {"customer_id":"2245303000022841066","custom_fields":[{"index":1,"show_on_pdf":false,"value":"2245303000144413026","label":"Sales Order"}],"line_items":[{"description":"Pet Door - WM-L (blk) Pet Door - WM-L (blk)","rate":379},{"description":"Pet Door - DM-L (brwn) Pet Door - DM-L (brwn)","rate":798}]}
Any guidance would be greatly appreciated.

    Nederlandse Hulpbronnen


      • Recent Topics

      • Zoho Projects - Attachments added to Task and Bug emails are not saved

        Hi Projects team, I have been experimenting with emails into projects to create tasks and bugs. I have noticed that attachments added to the emails are not saved to the task or bug. Is this normal behaviour? Thanks, Ashley
      • Zoho Projects - Email notification relabelling of modules not present on default templates

        Hi Projects Team, I noticed that in the default email template notification, the word "bug" was not renamed to the lable I am using in my system. As many users may used the Bugs modules for various purposes including Changes, Revisions, Issues, etc...
      • Zoho Projects - Unread Comment Icon

        Hi Projects Team, It would be great if there was a notification I con on the comments icon so it's easy to see which tasks have new comments. Something like a red circle with a number of unread comments would be great. Thanks for considering my feed
      • E-Invoicing in Belgium with Zoho Billing

        Starting January 1, 2026, Belgium is introducing mandatory electronic invoices (e-invoicing) for all B2B transactions between VAT-registered businesses. Invoices and credits notes must be exchanged in a prescribed digital format. How E-Invoicing works
      • Zoho Projects - Email Notifications for Feed Updates

        Hi Projects Team, I'm working with a client who wants a simple way to communicate with their customers on projects. Getting the customer to add comments to Tasks or Bug records is not ideal, as we need a way which is easy with minimal training, and has
      • Zoho Projects - Reply by email to @ mentions posted on the Feed.

        When mentioning someone on the Feed (Status), it would be great if that mentioned person could reply to the email notification to update the Feed thread.
      • Zoho Analytics Export API

        Hi Team, I’m working on some integration tasks and wanted to confirm if it’s possible to retrieve a Zoho Analytics table as JSON data using a Deluge script. I’ve already stored my custom data from multiple sources and combined it into a single source.
      • Unveiling Zoho Sites 2.0 - A new dimension in website building

        Dear Zoho Sites Users, We are thrilled to announce the launch of Zoho Sites 2.0 today! This refresh represents a significant step forward in the capabilities of Zoho Sites and is crucial for creating a lasting and positive impact on our customers' businesses.
      • Weekly Tips : Make collaboration effortless with Whiteboard in Zoho Mail

        Working with your team often means switching between emails, notes, and other applications just to explain an idea. Maybe you are trying to sketch a layout, plan a workflow, or quickly brainstorm ideas—with text alone, things can get confusing. So how
      • Zoho Projects - Update Feed via API

        Hi Projects Team, Please consider adding an API to allow update and retrieval of messages to the Feed. Thank you
      • Rich-text fields in Zoho CRM

        Hello everyone, We're thrilled to announce an important enhancement that will significantly enhance the readability and formatting capabilities of your information: rich text options for multi-line fields. With this update, you can now enjoy a more versatile
      • Hide fields only for creation

        Hello, I'd like to hide some fields only during the creation of a contact in Zoho CRM. In fact I have some fields that are automatically calculated thanks to an automation, so when my users create a contact I don't want them to fill those fields. I know
      • My go to On Load Client Script - Fast, efficient, and works for ALL profiles; Hides everything except initial fields

        This is my on Load client script that I use for Create pages. I use a modified version for Edit and Display pages which you can create yourself using the same basic structure that I will give you below. First up, the script. Below that will be an explanation
      • 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
      • Zoho Sites "pages" management page

        I have 80 plus pages on zoho sites. When I go to the "pages" link to view and edit pages, They are not in any kind of order, so I spend lots of time searching for pages when I need to edit or create new. How can I change the view order of all my pages
      • Introducing the all-new email parser!

        Greetings, We are pleased to introduce to you, a brand-new, upgraded version of the Zoho CRM Email Parser, which is packed with fresh features and has been completely redesigned to meet latest customers needs and their business requirements. On that note,
      • Exciting Updates to the Kiosk Studio Feature in Zoho CRM!

        Hello Everyone, We are here again with a series of new enhancements to Kiosk Studio, designed to elevate your experience and bring even greater efficiency to your business processes. These updates build upon our ongoing commitment to making Kiosk a powerful
      • Zoho Projects - Refine Access to Collaboration Menu

        Hi Projects Team, I noticed that Calendar, Chat and Meeting menu options in the Collaboration section are visible to client users, even when they don't have access to the features. This could be confusing and frustrating, because if it's there you expect
      • Zoho Projects - Add Feed to Project Tabs

        Hi Projects Team, I'm working on a lightweight communications requirement for one of my customers in relation to communicating with their client users via Zoho Projects. I noticed that the Feed is only available in the Collaboration section, but you can
      • Zoho Books Finance Modules Not Accessible in Zoho CRM Mobile App

        We have integrated Zoho CRM with Zoho Books using the Zoho Finance Suite integration. In the CRM web version, we can see the Finance modules (Estimates/Quotes, Invoices, Sales Orders, Items, Payments) and are able to create invoices and quotes directly
      • Zoho CRM Kiosk Upload Files

        Hello all, We are trying out Kiosks at the moment to see where it can fit best in our business. We are still a bit off in the application but lets say we will sort this out. My question is the following - when I create a Kiosk I can add "File Upload"
      • Connecting zoho creator to zoho writer to send prefilled documents

        i will paste the worflow below // Get user's submitted data from the form userSalary = input.Current_Salary; userCIBIL = input.CIBIL_Score; userEmail = input.Email; userName = input.Name; // You need to get the Document ID from the URL of your Zoho Writer
      • Extracting Images from a Zoho Creator Report into a Pages

        If you’ve uploaded images in a form and can see them in your report, you might also want to display those same images inside a Page (custom HTML page). This is useful for dashboards, profile pages, or any place where images should be visible dynamically
      • How do I change a form's name? Why isn't this more intuitive?

        Can someone please let me know how to change a form's name?
      • Zoho is blocking emails I subscribe to from one sender

        About 4 months ago I stopped receiving newsletters that I subscribe to from @thedispatch.com. They tell me that zoho's server is blocking them. I've added them to my contacts list, but they're not even reaching my inbox. I don't know how to troubleshoot
      • Introducing Formula Fields for performing dynamic calculations

        Greetings, With the Formula Field, you can generate numerical calculations using provided functions and available fields, enabling you to derive dynamic data. You can utilize mathematical formulas to populate results based on the provided inputs. This
      • Inactive Items - Make Less Prominent by Default

        Currently, when one marks an Item as "Inactive", it really doesn't do much of anything to hide it or get it out of the way. Search and reporting within Finance should, by default, hide inactive Items from standard reports, searches, etc. If one specifically
      • Items should display under specific warehouse

        I have configured the multi warehouse but it show all the items under all warehouse which is not correct according to our business logic, so i want that items should only display under that specific warehouse not under all the warehouses not even with zero quantity. Some items should be common but not all so is there any option for that purpose so i can specific the items to its warehouse. Regards
      • Zoho Analytics Bulk Api Import json Data

        HI, I’m trying to bulk-update rows in Zoho Analytics, and below are the request and response details. I’d like to understand the required parameters for constructing a bulk API request to import or update data in a table using Deluge. Any guidance on
      • Convert HTML to PDF & Send as Email Attachments in Zoho Creator (Deluge)

        This approach is useful for sending welcome letters, instructions, or promotional offers after order creation. // 1. Define the variables using the submitted input customerName = input.Customer_Name1; orderID = input.ID; customerEmail = input.Email_Address; //
      • Auto-fill New Row with Previous Row Values

        rowsize = input.Order_Items.count(); for each row1 in input.Order_Items { rowsize = rowsize - 1; if(rowsize == 1) { row.Door_Model = row1.Door_Model; row.Door_Color = row1.Door_Color; row.Materials = row1.Materials;
      • I am facing a problem with an if-else condition

        If I use if, else if, and else conditions in Deluge with the same variable name, sometimes the variable causes an error because the same variable name is present in every block
      • When I click on PDF/PRINT it makes the invoice half size

        When I click PDF / Print for my invoice in Zoho Books, the generated PDF appears at half size — everything is scaled down, including the logo, text, and layout. The content does not fill the page as it should. Could someone advise what causes Zoho Books
      • Python - code studio

        Hi, I see the code studio is "coming soon". We have some files that will require some more complex transformation, is this feature far off? It appears to have been released in Zoho Analytics already
      • API question - adding a thread to an existing ticket

        Hi Is there an API function for the customer to add to an existing ticket thread? example, customer puts in new support ticket. support replies and ask for more details. customer replies with more details -what api function is used for this (will add record append to same ticket number?) Thanks
      • search and Smart Bar both missing in Mail

        One of the users on my account does not have the search bar at the top right or the Smart Bar at the bottom left of the desktop Mail app. Any ideas how to get those back?
      • Why is Zoho Meeting quality so poor?

        I've just moved from Office 365 to Zoho Workplace and have been generally really positive about the new platform -- nicely integrated, nice GUI, good and easy-to-understand control and customisation, and at a reasonable price. However, what is going on
      • Items Below Reorder Point Report?

        Is there a way to run a report of Items that are below the Reorder Point? I don't see this as a specific report, nor can I figure out how to customize any of the other stock reports to give me this information. Please tell me I'm missing something s
      • Qwen as the default open source Generative AI model for Zia

        Hello everyone, Zia Generative AI is transitioning from Llama (8B parameters) to Qwen (30B parameters) as the default model. This means that users who were using Llama as a GenAI service will now use Qwen. This upgrade was made with a vision to enhance
      • Calendar week view: Today + 6

        Is there anyway to have the calendar change dynamically based on the date? Due to the amount of events, we only display a week at a time, but towards the end of the week, we can no longer see ahead to next week (without changing it manually every time).
      • Next Page