Updating an Invoice Line Item's Discount Account via API Call / Deluge Custom Function

Updating an Invoice Line Item's Discount Account via API Call / Deluge Custom Function

I need help updating an invoice line item's discount account via API. Below is a screenshot of the line item field I am referring to.

Now the field to the left of the highlighted field (discount account) is the sales income account. I am able to modify the sales income account via API completely fine.

I have a custom field called "Sales Account" with four options: Direct, Retail, Event, House Account, and Subscription. This field is in the invoices module.

This workflow has no criteria and immediately triggers the custom function "update_income_accounts," which fetches the invoice's "Sales Account" field value and runs through a series of if/else statements to determine the correct account ID for the sub-accounts nested under the main chart of accounts sales income account.


We're trying to automate updating the sales account association for all invoice line items by running this custom function.

So far, it works perfectly, except for the line item discount account. I can't get the invoice to reflect any changes to the discount account.


Below is the Zoho Books Custom Function I am using that works to update the Sales Income account but fails to reflect any change to the Discount account

  1. sales_account_value = "";
  2. account_id = "";
  3. discount_id = "";
  4. for each  custom_field in invoice.get("custom_fields")
  5. {
  6. if(custom_field.get("field_id") == "4366441000017151041")
  7. {
  8. sales_account_value = custom_field.get("value_formatted");
  9. }
  10. }
  11. if(sales_account_value == "Direct")
  12. {
  13. account_id = "4366441000017139067";
  14. discount_id = "4366441000036176472";
  15. }
  16. else if(sales_account_value == "Retail")
  17. {
  18. account_id = "4366441000017139058";
  19. discount_id = "4366441000036176510";
  20. }
  21. else if(sales_account_value == "Event")
  22. {
  23. account_id = "4366441000017134275";
  24. discount_id = "4366441000036176506";
  25. }
  26. else if(sales_account_value == "House Account")
  27. {
  28. account_id = "4366441000036176498";
  29. discount_id = "4366441000036176502";
  30. }
  31. else if(sales_account_value == "Subscription")
  32. {
  33. account_id = "4366441000041000009";
  34. discount_id = "4366441000041000015";
  35. }
  36. invoice_ID = invoice.get("invoice_id");
  37. line_items = Map();
  38. url = "https://www.zohoapis.com/books/v3/invoices/" + invoice_ID + "?organization_id=HIDDEN_FOR_HELP";
  39. invoice_details = invokeurl
  40. [
  41. url :url
  42. type :GET
  43. connection:"HIDDEN_FOR_HELP"
  44. ];
  45. line_items = invoice_details.get("invoice").get("line_items");
  46. item_to_update = List();
  47. for each  item in line_items
  48. {
  49. line_item_map = Map();
  50. line_item_map.put("line_item_id",item.get("line_item_id"));
  51. line_item_map.put("account_id",account_id);
  52. // set discount account via the discounts array
  53. discount_details = item.get("discounts");
  54. info discount_details;
  55. discounts_list = List();
  56. one_discount = Map();
  57. one_discount.put("discount_order",discount_details.get(0).get("discount_order"));
  58. one_discount.put("discount_amount",discount_details.get(0).get("discount_amount"));
  59. one_discount.put("discount_percent",discount_details.get(0).get("discount_percent"));
  60. one_discount.put("discount_account",discount_id);
  61. discounts_list.add(one_discount);
  62. line_item_map.put("discount_account_id",discount_id);
  63. line_item_map.put("discounts",discounts_list);
  64. item_to_update.add(line_item_map);
  65. info discounts_list;
  66. }
  67. info item_to_update;
  68. update_payload = Map();
  69. update_payload.put("line_items",item_to_update);
  70. update_invoice = invokeurl
  71. [
  72. url :url
  73. type :PUT
  74. parameters:update_payload.toString()
  75. connection:"HIDDEN_FOR_HELP"
  76. ];

      • Recent Topics

      • Zoho CRM Email Templates 100% Width No Background How?

        Hi, On the Zoho CRM Email Templates in setup > customization > templates > new templates > I choose blank template, but still it puts in a gray background and a max width for the email. I just want to make an email that looks like an email I would send from gmail that has no background or max width. How do you do this? 
      • Why Document Integrity Matters at Every Stage of the Contract Lifecycle

        Contracts are legal records that must stay authentic and traceable from creation to expiry or termination. In Zoho Contracts, several design decisions focus on protecting the integrity of every document. These measures ensure that no important details
      • affichage pièces jointes impossible

        Bonjour, aujourd'hui je n'arrive pas à afficher ni à télécharger les pièces jointes dans ZOHO CRM. J'utilise Chrome, j'ai vidé les caches et les cookies. Mais cela ne change rien. Merci de votre aide
      • Reminder to renew subscription.

        Whenever I try to add to one of my notes a " renew your subscription" window pops out and won't Close disallowing me to edit. Why should I renew my subscription on an application with at best such bugs and at worse such underhanded ways to force ren
      • Fields not coming through, not pulling data

        Forgive the noviceness of my vocabulary. I am in Zoho flow connecting CRM and Projects. When an opportunity hits a certain stage, it will create the project in Projects, and bring in data from the opportunity. Everything is working, except for two fields
      • Smartsheet Integration

        Has any in the community been able to integrate Zoho Desk with Smartsheets using Zoho Flow? I am trying to get the Smartsheet Row ID based on ticket data and cannot find documentation on the Get Row function for Smartsheet. It is asking for a Query String
      • CRM Campaign - how to mass remove contacts?

        Does anyone have a solution for removing all contacts from a CRM campaign. Seems that one by one is the only option. 
      • Send out follow-up email in the same thread (threaded conversations in individual emails) from Zoho CRM

        Hi, I'm new to Zoho. I'm trying to send individual emails to my leads one by one. And I'll send out follow up email if I don't hear back from them later. However, instead of sending a new email, I want to reply in the same email thread so that the recipients
      • Cadence Support in Zoho Vertical Studio

        We would like to know whether it is possible to create and configure Cadences in Zoho Vertical Studio, similar to the Cadence feature available in Zoho CRM. Please confirm if Vertical Studio supports creating cadences for modules and users, and whether
      • Removing "Products" as mandatory field from Sales Order creation page

        Hello, friends According to our workflow, we should: 1) create Sales Order (Stage "New") 2) call and discuss the Products with a customer (Stage "Communication") 3) add the Products to the Sales Order during the call However, "Products" is mandatory to
      • Zoho Books says "The customer "Hakimuddin P A Ali" already exists. Please specify a different name.""

        One of my transaction is not getting posted from Stripe to Zoho books. I already checked in Zoho books that there is no customer already present in Zoho books with the same name (as the error mentions) I already raised this complaint on Zoho flow portal,
      • Is it possible to automate a file to be directly uploaded to a specific subfolder in Zoho Workdrive?

        I am establishing a workflow so that when a new task is marked "complete", the document submitted in the task (under the "Documents" tab) is automatically uploaded to a specific subfolder in the associated WorkDrive for the project. However, the dilemma
      • Steuerberater der Zoho benutzt in Deutschland

        I write in English because the issue is related to German regulations. Wir sind ein Unternehmen, welches aktuell keine Pflicht zur doppelten Buchführung hat. Aktuell bucht unser Steuerberater jeden Beleg, auch unsere Auslagen. Wir würden dies gerne selbst
      • Why are some folders not showing up as an action trigger in Zoho Flow?

        I am currently working on a flow that automates the process of creating a folder in WorkDrive once a Task List is created. When I am selecting a destination for the folder, some projects are not showing up. I intend to create a folder within a specific
      • Getting Date from PostgreSQL error

        I am pulling data from PostgreSQL table into a CRM record via FLOW but the field is coming out empty. Need some suggestions: Field Type in CRM: Date/Time Field value in PostgreSQL: 2024-12-05 21:06:32.479 Field value in FLOW "Fetch Row": created : "2024-12-05T21:06:32.479382000",
      • Zoho Flow to SendOwl API error

        SendOwl is listed in the apps list of Zoho Flow. When trying to connect through the API with valid key and secret, the error given is: SendOwl says "HTTP Basic: Access denied" It seems Zoho doesn't connect via HTTPS. I've already tried using webhooks,
      • decisions based on content of a ticket

        Hi, I need to create a flow that sends automated email based on the content of a ticket in zoho desk. I have certain tickets that are formatted in a particular way, and contain certain keywords. How can I filter (based on decisions) the tickets based
      • Newline Character "\n" parsing problem in webhooks

        Hi there, I am facing an issue in Zoho Flow (maybe a general issue or maybe only in Zoho Flow): I have this function: void sendListWebhook(string url, list array) { for each arrayElement in array { result = invokeurl [ url :url type :POST parameters:arrayElement.toString()
      • One Company, multi branches, multi warehouses and I need to manage this in one organization

        Dears,  I'm a new user to zoho solutions,  however I found a lot of persons giving a nice feedback about it also a lot of good reviews. I though why we try to move to it in our company. I'm not sure if Zoho could give me all what I need or not that's why I'm going to post in this topic most of the things I know about managing our business to let you ,as zoho experts, tell me if Zoho will meet my business requirements or not. First of all we are a flowers and landscaping company we have like 6 to
      • Migration Evernote

        Bonjour Apres plus d'une dizaine d'année passer avec evernote j'ai décidé de franchir le pas . J'ai débuté par migrer mes notes vers zoho et depuis la migration est bloquée. Impossible d'avoir un retour du support malgré plusieurs mails et tentative d'appel
      • Pushing GCLID info from Gravity Forms to ZohoCRM

        We are switching to Gravity Forms from Zoho Forms and I cannot find any good info on how to make sure my GCLID tracking info is pushed through to the CRM through my new forms. There was an article in the documentation about placing something within the
      • Zoho OAuth Connector Deprecation and Its Impact on Zoho Desk

        Hello everyone, Zoho believes in continuously refining its integrations to uphold the highest standards of security, reliability, and compliance. As part of this ongoing improvement, the Zoho OAuth default connector will be deprecated for all Zoho services
      • On Zoho Flow, Record deleted trigger from Zoho Creator

        On creating flow in Zoho Flow, when we select app Zoho created, it provides 3 trigger options - Record created, Record updated and Record created or updated We need trigger on "Record Delete" as well, We have a use case to fire our system api if record
      • Zoho Flow Switch On Not Working

        I have created a flow which is when the mailbox address received the email that meet the condition will auto fetch the contact, account and finally create the ticket by using Zoho Desk. When I do a test and debug on my flow it work well as what I expect
      • MS Teams Flow Integration Question

        Where can I find the chat ID for the "Post message to chat" target?
      • Zoho Flow - Access denied to recover recording from call module - OpenAI

        Hi, I am trying to build a Flow to recover recoding when a new call is saved in my CRM. I have integrated my CRM with ringcentral and the recordings are saved in the event. Trigger: When new module entry Step 2: Fetch module entry (Zoho CRM says "permission
      • Unable to send price in big commerce from zoho flow.

        I am creating a flow from zoho flow to create a product in zoho inventory and sending this to big commerce. But the problem is like when ever i send the price its getting error. it require decimal format value if i am sending ${trigger.sales_rate} the
      • Not sending mail to new lead in zoho flow

        I have created a flow in zoho flow and triggered an action to send email notification when the new lead is created but even after user entering the mail id the email is not going to them
      • Access query string from incoming webhook URL in Zoho Flow

        I have a fairly straightforward use case, but cannot find anything conclusive on this subject. How can I simply access the query string of the incoming webhook request in Zoho Flow? I am attaching the Deal ID to the end of the request like: https://flow.zoho.com/762439902/flow/webhook/incoming?zapikey=1001.0dec2d7dd15080c464a13925275f0129.448c23ee219c545c89f5a178456cfc8b&isdebug=false&dealID=${Deals.Deal
      • Unable to access my Zoho forms account

        For some days now, I haven't had access to my Zoho Forms account. I keep getting an error that says, "You are an inactive user in your organization" via the mobile app and "You don't have permission to access this organization" via the web. I was removed
      • Custom Fonts in Zoho CRM Template Builder

        Hi, I am currently creating a new template for our quotes using the Zoho CRM template builder. However, I noticed that there is no option to add custom fonts to the template builder. It would greatly enhance the flexibility and branding capabilities if
      • Identify Unused Deluge Functions in Zoho CRM

        Hello Zoho Support Team, I would like to request a feature that helps administrators identify unused or rarely used Deluge functions in Zoho CRM. Currently, Deluge functions are distributed across different areas, and there is no centralized overview
      • User Automation: User based workflow rules & webhooks

        User management is an undeniable part of project management and requires adequate monitoring. As teams grow and projects multiply, manual coordination for updating users & permissions becomes difficult and can give way to errors. User automation in Zoho
      • Update on V2 API End-of-Life Timeline

        Dear Users, Earlier this year, we shared the launch of the V3 APIs and requested users to migrate from the older V2 APIs by December 2025. We have received valuable feedback from our users and partners regarding their migration timelines. We are happy
      • Run a workflow after record merge

        Hello, We are wondering if there is a way to trigger a workflow after two records are merged? We have a sms service that use to text back and forth with Prospects and Contacts. To make it easy for our users, we automatically create them in this other
      • Zoho Books' 2025 Wrapped

        Before we turn the page to a new year, it’s time to revisit the updates that made financial management simpler and more intuitive. This annual roundup brings together the most impactful features and enhancements we delivered in 2025, offering a clear
      • Live webinar | The Evolution of Zoho Show: 2025 Feature Recap

        2025 has been a year of exciting updates and features for Zoho Show. From advanced design and formatting tools to smarter presentation delivery, enhanced collaboration, and AI-powered features—along with the launch of our desktop apps, Show has continued
      • Batch Tracking custom function

        Hi fellow zoho users, We have our ecommerce site setup to shopify. I have some products I want to add batch tracking too, my only issue is that it breaks our shopify workflow (create sales order, invoice, payment, package) because it requires us to manually
      • Company Multiple Branch/ Location Accounting

        Hi All, anyone know whether company can maintain their multiple Branch Accounting in Zoho  Books. It will be chart of Accounts & Master Data will be same but different report available as per per Branch. Thanks & regards, Vivek +91 9766906737
      • Is it possible to setup bin locations WITHOUT mandating batch tracking?

        Hi fellow zoho users, I'm wondering if anyone else has a similar issue to me? I only have some products batch tracked (items with shelf life expiry dates) but I am trying to setup bin locations for my entire inventory so we can do stock counting easier.
      • Next Page