Function #57: Automatically group items in invoices based on categories

Function #57: Automatically group items in invoices based on categories



Hello everyone, and welcome back to our series!

As a business expands and new product lines are launched, it becomes important to organize the items for better inventory management. The Category field in Zoho Books helps here by allowing you to add and assign categories to group items effectively. You can even create sub-categories under a parent category for more specific organization. The Sales By Category report provides insights into the performance of each category, helping you make informed business decisions. Today's function revolves around this Category field. It aims to automatically sort items added to an invoice based on their categories and display the category names as headers. 



Consider Mr. John Hector, who runs a wholesale stationery shop. When a customer orders various items such as pens, paints, paint brushes, color palettes, and desk supplies from different categories, John raises an invoice in Zoho Books to record the sale. Once the invoice is saved, the custom function is executed to organize the items by their categories and add the category names as headers. For example, items related to art—like paints, paint brushes, and color palettes—are grouped under "Art Supplies." Similarly, other items will be grouped under their respective category headers, and any uncategorized items will be listed under the header "Others". This organized layout helps both John and his customers easily understand the assortment of items on the invoice. 



Note: The Category field will be accessible in Zoho Books after enabling the Zoho Inventory add-ons. 

Prerequisites:
 
1. Create a Connection named "zbooks" to successfully execute the function. You can watch the GIF attached below to know how to create the connection.



2. To enable the "Category" field, go to Zoho Books > Items > Field Customization > Hover over the Category field > Click on the dropdown menu and select "Mark as Active".



Custom Function:

Navigate to Settings -> Automation -> Workflow Actions -> Custom Functions -> +New Custom Function > Add the function code from this GitHub link -> Save. 

Workflow Rule:

Go to Settings -> Automation -> Workflow Rules -> +New Workflow Rule and set up the workflow rule as shown below:-





In the final step of this workflow rule, associate the custom function you created and then hit Save.

If you need assistance with implementing this function, please contact our Support team at
support[at]zohobooks[dot]com. We are happy to help.

Regards,
Shireen Farhana
Zoho Books 


        Zoho Campaigns Resources


          • Desk Community Learning Series


          • Digest


          • Functions


          • Meetups


          • Kbase


          • Resources


          • Glossary


          • Desk Marketplace


          • MVP Corner


          • Word of the Day


          • Ask the Experts


            Zoho CRM Plus Resources

              Zoho Books Resources


                Zoho Subscriptions Resources

                  Zoho Projects Resources


                    Zoho Sprints Resources


                      Zoho Orchestly Resources


                        Zoho Creator Resources


                          Zoho WorkDrive Resources



                            Zoho CRM Resources

                            • CRM Community Learning Series

                              CRM Community Learning Series


                            • Tips

                              Tips

                            • Functions

                              Functions

                            • Meetups

                              Meetups

                            • Kbase

                              Kbase

                            • Resources

                              Resources

                            • Digest

                              Digest

                            • CRM Marketplace

                              CRM Marketplace

                            • MVP Corner

                              MVP Corner




                              Zoho Writer Writer

                              Get Started. Write Away!

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

                                Zoho CRM コンテンツ


                                  ご検討中の方

                                    • Recent Topics

                                    • Trace topping failures with Function Logs

                                      Hello everyone, Debugging a topping issue used to mean starting from scratch, with no visibility into what its custom functions actually did or where things broke. Function Logs change that; for any topping installed in Bigin, you can now see the execution
                                    • Zoho Desk API returning 403 SCOPE_MISMATCH for Ticket Search API

                                      Hello Zoho Support Team, We are experiencing an authorization issue with the Zoho Desk Ticket Search API. Our integration was working correctly yesterday, but we are now receiving the following error when calling the Search Tickets endpoint: API: GET
                                    • Category codes in General Ledger

                                      Creation of category codes in general Ledger
                                    • Question about Zoho CRM Professional plan users

                                      Hello! I have a question about the Zoho CRM Professional plan. Is the pricing charged per user or per organization? Are there any free users included in this plan, or do I need to pay for each additional user separately? Thank you!
                                    • All new Address Field in Zoho CRM: maintain structured and accurate address inputs

                                      Availability Update: 29 September 2025: It's currently available for all new sign-ups and for existing Zoho CRM orgs which are in the Professional edition exclusively for IN DC users. 2 March 2026: Available to users in all DCs except US and EU DC. 24
                                    • ZOHO EMAIL ALIIES AS101 ERROR

                                      Hi zoho team, I am having this issue AS101:Internal Error occurs when creating under USER TAB - email allies. please guide me and can you help me to fix issue from your side. ASAP 
                                    • Remove the mandatory Name Card buttons (or at least make them optional)

                                      Please remove the mandatory Name Card buttons (or at least make them optional) A recent change to the Name Card in Zoho SalesIQ (currently affecting WhatsApp) introduced mandatory buttons before a visitor can provide their name. I believe this change
                                    • Ticket duplicating when multiple "To Address" are messaged

                                      Hello, I want to know if there is a way that I can stop the duplication of tickets when clients email multiple emails related to the same department at the same time. In our case, we basically use ZDesk like email. Each agent has a designated "To Address"
                                    • Looking to Auto-Merge Duplicate Tickets

                                      Hi guys, I need the option to auto-merge duplicte tickets and i dont see this option available in automation , Can this be done? And if so how, Cheers
                                    • Add bulk ticket merge functionality in Zoho Desk

                                      Hi Zoho Team, We would like to request a feature that allows agents to merge multiple tickets in bulk instead of merging them one by one. Current Limitation At the moment, tickets can only be merged individually. This becomes very time-consuming when
                                    • Spell Check Icon Disappeared yesterday for Agent Comments

                                      We always use "Public Comment" when communicating on tickets with our customers. For years we had the "Spell Check" icon when typing a comment. Yesterday, this icon disappeared for comments and is only avaialable when drafting a response via "Reply."
                                    • Spell Checker in Zoho desk

                                      Is there a way to set always check spelling before sending? Outlook does this and it is a handy tool to avoid typos
                                    • Adding additional records dynamically to a subset of fields

                                      I'm trying to create a service ticket layout which will be passed to a Creator application for Field Service Management (FSM) purposes. We need to be able to define a specific subset of service product fields such as "Service Product", "Service Product Serial Number", "Service Product Warranty End Date" and "Service Product Current Warranty Status". We may need to record more than one of these subsets, in case the customer has more than one product which has to be serviced on their site. It seems
                                    • When Will Existing Zoho Campaigns 2.0 Orgs Convert to 3.0?

                                      Hi Zoho team, I'm very excited to start using Campaigns 3.0, but I don't see any notifications related to moving my org to the new version. What is the roll-out plan for existing users? Thanks
                                    • Date Override hangs

                                      When trying to add date overrides, the system hangs on save and never goes through.
                                    • Date Selection?

                                      Is there no way to select a specific date in bookings? For example we have evaluations certain Saturday's a month and would like to be able to book just for those dates. Is there anyway to do this?
                                    • Zoho Desk API Custom Module not all data is showing up

                                      When i get a record by id for my new module: responseDetailed = invokeurl [ url :"https://desk.zoho.eu/api/v1/cm_tickets_CM/" + record.getJSON("id") type :GET parameters:"" connection:"desk_connection" ]; The response doesnt contain all fields, the field
                                    • Unable to receive email from domains related to arib.com. Zoho error in reports mention error 554 5.7.1 rfc not compliant

                                      Dear Zoho experts, I am not able to receive email from domain ariba.com and ansmtp.ariba.com. When I check the delivery logs of my Zoho account it shows the status as 'failure' and reason mentioned is 554 5.7.1 This mail is rejected as it is not RFC compliant.
                                    • Pausing journey's over holiday's

                                      Has anyone found a work around to pausing journey's for a brief time (around holiday's) and turning them back on after? My understanding is freezing the journey only keeps new leads from entering, not pausing the leads already in the journey.  Thank
                                    • Trying to show the actual Terms & Conditions on PDF

                                      Hi, On Zoho forms I am trying to have the actual terms and conditions that the user needs to accept also show on the pdf that they receive after. Right now it only says "Agreed". Please help.
                                    • Using decisions box as condition for a script "on validate"

                                      Hello, I have a script on validate to check few thing and cancel submission if need be. The script works perfecly. I add a condition (admin permission) for that script not to be initiated if a decision box is checked (I also tried radio button). I use
                                    • How to stop ex-employees of client companies from logging in to a Zoho Creator portal with MFA?

                                      Hi everyone, I manage a Zoho Creator portal for our clients and have a security concern about MFA for portal users. I’d like to know if anyone has faced this and how you handled it. Setup Creator plan: Enterprise “Enforce Multi-Factor Authentication (MFA)
                                    • [Free webinar] Learning Table Series | Chat with intent: From conversations to intelligent actions

                                      Hello everyone, We are excited to invite you to another edition of the Learning Table Series webinar. With AI-powered capabilities, the way users interact with applications is evolving. Instead of navigating multiple screens to find information, users
                                    • how do I move email responses to the top of the of the email body?

                                      when someone responds to my email, their response is at the very bottom of the email. I have to scroll down to the bottom to see what they wrote. how can I move the response to the top of the email?
                                    • OTP New email access

                                      adding a new email sends a OTP code to the new email which I can't access. It send an OTP code but I can't access it without getting the new OTP code.
                                    • M

                                      Hi Zoho Support team, I got notification error in my email account when i sending email to my client (reply). It said that i exceeded limit 1600 send email per day, however i never reach that number. Could you check that ?
                                    • How do I reorder the item table columns in my invoice template?

                                      There must be a way I just cannot find it. Anyone?
                                    • API - Add Tags to Search Articles

                                      The ability to "search articles" programmatically via API would be meaningfully enhanced by allowing that search to filter for (or out) certain tags. There are lots of potential use cases here. The one that caused me to write this post is for agentic
                                    • [Webinar] AI-powered writing and automation in Zoho Writer

                                      Live webinar on November 12, 2026 | Time: 2 PM IST | 2 PM EST Hi, When organizations create documents, they often start from scratch. Then they need to proofread and translate them. Doing all of this manually takes time, and errors and hard-to-read writing
                                    • What is "Child Sales Order"

                                      When I click system predefine "Created Sales Order" button, sometimes will display "Create Child Sales Order" instead of "Create Sales Order", in "Child Sales Order" Create Page, system will not allow you to save the record. only one solution is refresh
                                    • Zoho Tables is now live in Australia & New Zealand!

                                      Hey everyone! We’ve got some great news to share — Zoho Tables is now officially available in the Australian Data Center serving users across Australia and New Zealand regions! Yes, it took us a bit longer to get here, but this version of Zoho Tables
                                    • Enhancements for Currencies in Zoho CRM: Automatic exchange rate updates, options to update record exchange rates, and more

                                      The multi-currency feature helps you track currencies region-wise. This can apply to Sales, CTC, or any other currency-related data. You can record amounts in a customer’s local currency, while the CRM automatically converts them to your home currency
                                    • Introducing parent-child ticketing in Zoho Desk [Early access]

                                      Hello Zoho Desk users! We have introduced the parent-child ticketing system to help customer service teams ensure efficient resolution of issues involving multiple, related tickets. You can now combine repetitive and interconnected tickets into parent-child
                                    • ZoHo Mail & MCP connectors

                                      Is ZoHo working an MCP connector for mail?? I find it very useful in Gmail to have Claude summarize messages for me. Thanks Jim P.S. Sorry if this is the incorrect forum. Mods please adjust as necessary.
                                    • Optimize your Knowledge Base for better visibility by allowing search engine crawling and indexing

                                      All you need to know about no-follow and no-index in KB. What are article crawlability and indexability? Crawlability and indexability are vital for making an article visible and accessible to search engines. When a search engine crawls an article, it
                                    • Team ticket accessibility when tickets are set to private

                                      Hello! I would like to know if agents would be able to see tickets assigned to their team (but not to any specific user) if ticket sharing was set to Private. Thanks in advance, Luca
                                    • Now you can bring your Zoho Tables data to AI Assistants with Zoho MCP!

                                      Imagine asking your AI assistant questions about your Zoho Tables data, exploring records, or getting insights — all through natural language. With Zoho MCP (Model Context Protocol), you can connect Zoho Tables to compatible AI assistants and let them
                                    • Followed Tickets view

                                      Hello, following a ticket makes no sense at all / offers no additional value.... Of course I can install and use the add-on My Followed Tickets for Zoho Desk, but what does it do for me? Not much! It cannot be used across departments! The range of functions
                                    • iPhone Duo support for Zoho Desk app?

                                      When is iPhone Duo support expected for the Desk app? It’s miserable to use in its current form on the device. Please optimize for the new Duo!
                                    • Zia AI capabilities now available in all paid editions

                                      Hello everyone, We are expanding the availability of AI-powered features in Desk to the other paid subscriptions from 7th July 2026. Right now, the following AI-based features are available for Enterprise edition users: Intelligence: Sentiment analysis,
                                    • Next Page