Tip #3 Automating total item weight calculation for your sales orders in Zoho Inventory

Tip #3 Automating total item weight calculation for your sales orders in Zoho Inventory

Hello,


Hope the day is treating you well.
Last week, we saw how we could automate the calculation of total shipping charges from numerous shipments for your sales orders and invoices. This week, we will see how you can automate the calculation of total item weight for your sales orders. 

How does this work?
First, you are required to capture the weight of all your items using a custom field. And when you create a sales order, you can either have the system display the individual weights for you or you can manually enter new weights. You are also required to define a custom field under sales orders and packages called Weight to capture the total package weight. Through the custom function, the system will then add up the individual weights of items to arrive at a total weight and display it on your sales orders and packages. Later when you ship via a carrier, you can refer manually to this weight and input them into the shipment order to generate shipping rates.

Note: This custom function works only if a sales order has a single package. If there are multiple packages, then please note that this function will display the total weight of all items in the sales order inside of every package and not the total weight of items present inside that package. 

What do you need before writing the custom function?

How do I set it up?

Log in to your Zoho account and click on this link to generate an Auth Token which is required to make this work.

 
  • Open your Zoho Inventory organization.

  • Navigate to Settings using the gear icon from the top-right corner.

  • Select Automation from the sidebar. Now click on the button adjacent to +New Workflow Rule.

  • Out of the four options from the drop-down, select Custom Functions.

  • Now let's add a name for this workflow rule and make sure that there are no spaces between words.

  • Choose "Sales Orders" against the module field.

  • Add a description if you need one.

  • Now, the workflow type is going to be "Event Based".

  • And for the trigger, we are going to choose the option - "when a Sales Order is created".

In the deluge pane, we are going to copy and paste the following code snippet:


authtoken = "Copy and paste your authtoken here";
salesorderID = salesorder.get("salesorder_id");
salesorderdate = salesorder.get("date").toDate();
organizationID = organization.get("organization_id");
bson=Map();
lineitems=salesorder.get("line_items").toList();
weight=List();
for each line in lineitems
{
cfs=line.get("item_custom_fields").toList();
for each cf in cfs
{
if(cf.get("label").toString().equalsIgnoreCase("weight")) /*replace with item level custom field name*/
{
weight.add(cf.get("value").toDecimal() * line.get("quantity"));
break;
}
}
}
wei=0;
j=0;
for each index j in weight
{
wei=wei + weight.get(j).toDecimal();
}
info wei;
cf=List();
cf1=Map();
cf1.put("label","Weight"); /* replace with sales order custom field */
cf1.put("value",wei);
cf.add(cf1);
customs=salesorder.get("custom_fields").toList();
customs.addAll(cf);
bson.put("custom_fields",customs);
bson.put("customer_id",salesorder.get("customer_id"));
res=zoho.inventory.updateRecord("SalesOrders", organizationID,salesorderID, bson);
info res.toMap().get("message");

  • Before you save, you are required to copy and paste your auth token inside the quotes in the 1st line that says:

    • authtoken = "Copy and Paste your auth token in place of this text";

    • The auth token is a critical piece of information that helps the system identify you, so keep yours safe and confidential. Do not share it with anyone, not even folks from Zoho.

  • Now, hit Save to finish.

Henceforth, the total weight of all your items in a sales order you make will be calculated automatically and updated to the package that is associated with it. 

Don't use this, if you have multiple packages for a single order.


Hope this makes shipping a little more easier for you. Have you tried custom functions for your business? Email us your recipes (scenarios and code snippets), questions and suggestions to support@zoho-inventory.com.


Until next time!


Your everyday end user,

Ajay Aadhithya Chandrasekaran

Zoho Inventory



    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





                                                          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

                                                                                                          • Weekly Tips : Stay in loop with Conversation View

                                                                                                            You receive a series of emails back and forth with a client regarding a project update. Instead of searching through your inbox for each separate email, you would want to see the entire email conversation in one place to understand the context quickly
                                                                                                          • Introducing Zoho PDF Editor: Your free online PDF editing tool

                                                                                                            Edit your PDFs effortlessly with Zoho PDF Editor, Zoho's new free online PDF editing tool. Add text, insert images, include shapes, embed hyperlinks, and even transform your PDFs into fillable forms to collect data and e-signatures. You can edit PDFs
                                                                                                          • RSC Connectivity Linkedin Recruiter RPS

                                                                                                            It seems there's a bit of a push from Linkedin Talent Solutions to keep integrations moving. My Account Manager confirmed that Zoho Recruit is a Certified Linkedin Linkedin Partner but does not have RSC as of yet., (we knew that :-) She encouraged me
                                                                                                          • Water-Scrum-Fall approach for finance institutions with Zoho Projects Plus

                                                                                                            Finance is a highly regulated sector with strict rules and compliance requirements. Handling sensitive client data and complex transactions like multi-currency deals requires elaborate workflows and precise management. Implementing project management
                                                                                                          • Get instant summaries of your notes with the help of Zia

                                                                                                            Hello all, We've added a simple yet powerful feature to Zoho CRM that we're excited for you to try: Zia Notes Summary. It's designed to make the daily lives of a CRM user a bit easier by giving you quick summaries of your CRM notes. Whether it's a glance
                                                                                                          • Zoho one web page are not available

                                                                                                            Why I am not able to enter to zoho one web page?
                                                                                                          • Zoho People > Onboarding > Candidate do not view all the data field on the Employee Onboarding

                                                                                                            Hello In my onboarding portal I do not see all the fields that i want the candidate to fill in In my Employee Onboarding Form These details i can see In the work information, i have enable the Company View but in the Employee Portal i do not see I have
                                                                                                          • Has anyone implemented a ""switch"" to redirect emails in production for testing?

                                                                                                            Hi everyone, In our production Zoho CRM we have a fairly complex setup with multiple Blueprints and Deluge functions that send emails automatically — to managers and internal staff — triggered by workflows. We’re looking for a way to *test changes safely*,
                                                                                                          • Restrict Access/Shared Access

                                                                                                            Sometimes access to documents that go out from Zoho Sign need to be restricted or shared. For example: 1) HR department send out employment contracts. Any Zoho Sign admin can view them. Access should be restricted to those that HR would allow to view
                                                                                                          • Tip#44: Integrate with Xero to manage your financial operations

                                                                                                            Managing your project finances becomes more efficient with Xero integration in Zoho Sprints. With this integration, you can sync your Zoho Sprints data with Xero. Once you sync them to Xero, you can easily create invoices in Xero. This feature significantly
                                                                                                          • Zoho People Onboarding Unable to Convert to User

                                                                                                            Hello All I need help in this onboarding of candidate Currently at this stage the candidate is just being offered and we are filling in his details however not all information are fill up. The candidate is still using his/her personal email When i try
                                                                                                          • Integration with SharePoint Online

                                                                                                            Is there an integration where we can add a Zoho Sign link to the context menu of a document in the SharePoint document library. Then, we could directly initiate a workflow of sending a document for signature from a document library in SharePoint onl
                                                                                                          • White screen when connecting Zoho Cliq and Zoho People for birthday notifications

                                                                                                            Hi everyone, I'm new to Zoho and I'm trying to set up the employee birthday notifications, following this guide: Automating Employee Birthday Notifications in Zoho Cliq But when I try to connect Zoho Cliq with Zoho People, I just get a white screen and
                                                                                                          • Word file is messed up when i upload it to zoho sign

                                                                                                            Hi. I am trying to upload a word file to zoho sign and when i do that it ruins the file, It adds spaces and images are on top of each other. What can i do? Thanks.
                                                                                                          • Annotate widget?

                                                                                                            Is there something in creator or any zoho app that allows me to have an image markup field item in the form? I need to be able to complete a form that also allows the user to mark up a preloaded image. Other compay's call this an image markup field or
                                                                                                          • Dashboards / Home Page - Logged In User

                                                                                                            Lots of the dashboards that we use reference the Logged In User.  We also set up Home Pages for specific roles, where the Logged In User is referenced within the custom view.  As an admin, that means that these views are often blank when customizing and
                                                                                                          • I'm pissed as fuck

                                                                                                            What the hell Zoho! Always the same goddam problem. It takes time because the simplest things just don't fucking work. Today it just took me 3 hours to complete and send a 1page privacy letter to a client. And you know what 99% of the document was already
                                                                                                          • Configure Notifications for API Limit

                                                                                                            Hello developers, APIs are essential for businesses today as they enable seamless integration between different software systems, automate workflows, and ensure real-time data sync. To ensure that admins are notified well in advance before APIs reach
                                                                                                          • Introducing Blueprints for Custom Modules!

                                                                                                            Hello developers, We've added a new feature called Blueprints in Custom Modules. Blueprints are the online representation of a business process. In Zoho Books, you can use Blueprints to design a process flow using states and transitions. Developers can
                                                                                                          • Campaign Links Blocked as Phishing- Help!

                                                                                                            We sent a Campaign out yesterday. We tested all of the links beforehand. One of the links is to our own website. After the fact, when we open up the Campaign in our browser, the links work fine. The links in the emails received, however, opened in a new
                                                                                                          • Zoho Tables July 2025 Update: Smart Creation, Smarter Automation

                                                                                                            We’re excited to introduce a powerful set of updates across Web, Android and iOS/iPad apps. From AI-assisted base creation to advanced automations and mobile enhancements, this release is packed with features to help you build faster, automate better,
                                                                                                          • Zoho Voice est désormais en France !

                                                                                                            Nous avons des nouveautés très intéressantes qui vont transformer la façon dont vous communiquez avec vos clients. Zoho Voice, la solution de téléphonie d'entreprise et de centre de contact basée sur le cloud est arrivée en France ! Vous pouvez enfin
                                                                                                          • Numbers in MA

                                                                                                            I have an issue rationalising the various numbers around MA2. Not convinced that any are truly accurate. However have a specific problem in that i have a list with 1301 records in the list view. When i come to email there is only 1289 Then have another
                                                                                                          • Android mobile app unable to log in

                                                                                                            When I open the mobile up for zoho mail it asks me to sign in, but when i push the sign in button nothing happens. Tried uninstalling and reinstalling still not working
                                                                                                          • Pie chart in Zoho Analytics shows ridicoulous numer of decimals of a percentage.

                                                                                                            Is there a way to set the number of decimals of a percentage value in the Pie chart? Now it displays 15 decimals instead of a round-off value. The value is a count and percentage calculated in the chart, so there is no number of decimals that can be specified
                                                                                                          • Zoho People > Leave Management > Unable to import balance leave

                                                                                                            Hello Zoho I am unable to import balance leave into the system I have follow the steps It show only 5 fields - the date field i am unable to select from date and to date Error Date in excelsheet
                                                                                                          • Narrative 4: Exploring the support channels

                                                                                                            Behind the scenes of a successful ticketing system - BTS Series Narrative 4 - Exploring the support channels Support channels in a ticketing system refer to the various communication methods that customers use to contact a business for assistance. These
                                                                                                          • Tip of the Week #65– Share email drafts with your team for quick feedback.

                                                                                                            Whether you're replying to a tricky customer question or sharing a campaign update, finding the right words—and the right tone—can be tough. You just wish your teammates could take a quick look and give their suggestions before you send it. Sometimes,
                                                                                                          • How to Initiate WhatsApp Message on SalesIQ?

                                                                                                            I've just activated a Business WhatsApp phone number through SalesIQ because of its touted omnichannel chat approach. Sounds exciting. I understand that when a customer sends me a WA message, I can reply to it on SalesIQ and keep the chat going, perfect.
                                                                                                          • Episode IV:Handling User Inputs in custom functions

                                                                                                            Hi Everyone, We've been exploring custom functions which help in performing advanced automation tasks. Custom functions enable you to achieve possibilities based on your organization's requirements. Custom functions require user inputs that allow the
                                                                                                          • Set a lead as non-marketing if they opt out of email marketing

                                                                                                            I'm gathering Lead data via an enquiry form and wish to give them the option to opt out of marketing emails (which we send from Marketing Automation) whilst retaining the ability to send them non-marketing emails - so the email opt-out field doesn't work.
                                                                                                          • Set up multiple IMAP email addresses

                                                                                                            Hi, I just started using CRM and its great, but I just found out I can only add one imap email address for incoming mail in the included salesinbox ...this is ridiculous. All companies have different email such as sales@domain, info@domain , personal@domain
                                                                                                          • Zoho Recruit to Zoho People integration

                                                                                                            In the mapping of field from Zoho Recruit to Zoho People i am unable to map all fields What can i do
                                                                                                          • Zoho Recruit > Career Site > Customisation

                                                                                                            Hi All I have created multiple career site to represent my different organization In my Quanta Media career site > I set it with the with Quanta Malta view In my job opening : Quanta Malta view 2 job opening In my URL for quanta media https://lri.zohorecruit.eu/jobs/Quanta-Malta
                                                                                                          • Formatting Blueprint Stages (buttons)

                                                                                                            Is there a way to format Blueprint transition buttons in Creator like background colour, text colour etc.
                                                                                                          • Disable Default Value in Multi-Select field

                                                                                                            Hello, Is there a way to disable the default value feature when setting up a custom Multi-Select field? When creating tickets I would like it so there isn't a value pre-selected in the multi-select custom field that was created.
                                                                                                          • How to set custom business hours for different teams in Zoho Desk?

                                                                                                            Hi Zoho Team and Community, I’m trying to set different business hours for multiple departments in Zoho Desk. For example, our tech support team works 24/7, while our billing team is only available from 9 AM to 5 PM (Mon–Fri). Is there a way to assign
                                                                                                          • Zia Auto Tag Keyword Clusters

                                                                                                            Is there a way to remove a keyword from a keyword cluster? We're finding that Zia auto-tag is tagging things incorrectly based on some words that don't really make sense.
                                                                                                          • Centralized Domain Verification in Zoho CRM Plus

                                                                                                            Hi Team, I have a suggestion regarding Zoho CRM Plus. It's quite frustrating to verify the same domain separately for each application within the suite. It would be really helpful if you could introduce a centralized admin console—similar to what's available
                                                                                                          • HOw do I make a refund?

                                                                                                            I have a client that needs a refund. I see a refund history in the Report area... but where do I go to make a refund?
                                                                                                          • Next Page