Process FOR loop for subform items in the order of the manual sorting

Process FOR loop for subform items in the order of the manual sorting

Hi Guys, 

I have searched everywhere and tried everything, but I still not able to resolve one particular challenge. 

I have a subform in my Invoice with rows for each item. I made it so that we can change the order of the items manually. I need to be able to run FOR loop to process all items in the exact order they were re-arranged manually, but whatever I do - it always picks up in the order the records were initially added. Surely there must be some kind of Order/Sorting ID or metadata that can be used to process items in the exact order they are on the subform list (simply because when form is loaded, somehow Creator already knows what exact manual sorting order records are in)

Would you please be able to give me some guidance on how to do this?

Ultimately, I need to be able to calculate correct balance for each row when sorting is changed manually:

For example:

Original sorting:

Item | Amount | Balance
Rec1 | $10 | $10
Rec2 | $20 | $30
Rec3 | $30 | $60

Manual sorting - note that Balance should be re-calculated correctly for each row. I am doing it on form-submit, so, I intend to run this calculation every time the form is submitted, even if no sorting was changed. This is to ensure we have correct amounts and balances every time invoice is submitted.

Item | Amount | Balance
Rec3 | $30 | $30
Rec2 | $20 | $50
Rec1 | $10 | $60

I am doing basic FOR loop:

running_balance = 0;
for each i in input.items_list
{
   running_balance = running_balance + i.Amount;
   i.Balance = running_balance;
}
input.Total_Balance = running_balance;

At the moment I am not displaying balance on the invoice, as it is always wrong if sorting is changed (FOR loop seems to be always processing records in the order of subform item IDs, not in the order they are sorted manually).

I do have overal total balance, which is correct, but having running balance on each row is super handy as we can easily see over time how it is changing and it is also so much easier to visually assess current state of the invoice and have it as a reference point. 

    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



                                          Zoho Marketing Automation


                                                  Manage your brands on social media



                                                        Zoho TeamInbox Resources

                                                          Zoho DataPrep 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

                                                                                                  • So many tools...

                                                                                                    As a low- to no-code user and no funds to budget, there are so many options to choose to get my work done and when I start thinking about workflows for people other than myself, I get confused about the most streamlined way to move forward if I can get
                                                                                                  • Custom TaskList and Tasks creation based on project custom field

                                                                                                    Hello, I'm trying to configure Zoho Project for a specific use. I have created a custom multiselection field in project template and I would like to create one tasklist with multiple tasks in it depending on the multiselection field on each project. For
                                                                                                  • Zoho Creator to Zoho Books

                                                                                                    Hi, I use Zoho Creator and Zoho Books. I use Creator to produce and send invoices (for specific reasons) but want to create a corresponding invoice in Books. Has anyone done this and if so, how? I have the following documentation but can't make sense
                                                                                                  • Subform Zoho Form to Creator

                                                                                                    Hi, I would like to be able to retrieve the values of a Zoho Form subform to create an entry for each in Zoho Creator. To send from Form to Creator, I use Zoho Flow. I have a custom function, which should normally retrieve each field value then create
                                                                                                  • Multi Select Between Modules

                                                                                                    Hi, I'm not sure if this is possible, but I want to "import" or "mirror" the multi select options from one module to another. For example... I have Module "Clients" with a Multi Select Field of "Enrolled Services" I also have a Module "Services" with
                                                                                                  • Doesn't Catch Duplicate Accounts

                                                                                                    Zoho is very bad at catching duplicate accounts. If we have an account in Zoho, and we import the same account but with "Inc." or "LLC", it doesn't catch it, it just duplicates it. When importing from another app (like ZoomInfo) I set it to catch duplicates
                                                                                                  • 554 5.2.3 MailPolicy violation Error, help?

                                                                                                    This message was created automatically by mail delivery software. A message that you sent could not be delivered to one or more of its recipients. 554 5.2.3 MailPolicy violation Error delivering to mailboxes I am not sure why i am getting this, please
                                                                                                  • New Customization options in the module builder: Quick Create and Detail view

                                                                                                    Hello everyone, We have introduced two new components to the module builder: Quick create and Detail view. The Quick Create Component It is a mini form used to create a record and associate it to the parent record from a lookup field. For example, if you have a Deals lookup in the Contacts module, then you can associate existing deals or create a deal and associate it with the contact. You can customize this Quick Create form by adding standard as well as custom fields. There is no limit to the number
                                                                                                  • Créer un second centre d'aide dans Desk

                                                                                                    Bonjour, je souhaiterai pouvoir créer un second centre d'aide dans Desk afin d'avoir un service complètement indépendant du premier. Le premier fonctionne bien, il est pour notre service client. Mais j'aimerai maintenant pouvoir créer un nouveau service
                                                                                                  • Client Script | Update - Introducing Subform Events and Actions

                                                                                                    Are you making the most of your subforms in Zoho CRM? Do you wish you could automate subform interactions and enhance user experience effortlessly? What if you had Client APIs and events specifically designed for subforms? We are thrilled to introduce
                                                                                                  • Email Campaigns overview page is missing SENT DATE and # people sent to!

                                                                                                    I would like to see the date the email campaign was sent, so I can understand and track when each email campaign was sent. Right now, unless you go to a contact who received a campaign, you cannot see when the campaign was sent (!!!!!!). So, if my boss
                                                                                                  • Create an event from mail

                                                                                                    From mail I can create a task but I cannot create an event.  What am I missing?
                                                                                                  • How to customize Check Out form, process & design

                                                                                                    Hi Just set up my first shop and changed the design quite a bit. Like it so far! However, did not manage to change either Design, nor Content, nor Process of the Check Out. Where can I change this? E.g. - change the font of the check out forms - change
                                                                                                  • How do I use Deluge to search a Ticket by its Account?

                                                                                                    Usecase: with Zoho Flow, my task is to filter Tickets in Zoho Desk based on a few criteria and then use that information to edit and invoice in Zoho Billing. To achieve that, I'm using the Deluge search API to get all tickets from each Account (our clients)
                                                                                                  • Issue with bulk importing into commerce (updating existing products)

                                                                                                    Hello All, I'm struggling to bulk update my existing products within my shop. I have exported all the products and appended the image url (copied from another product within the file) and then important back into commerce. The file is accepted but flags
                                                                                                  • Option to Re-order from past orders

                                                                                                    Customers would like to place a repeat order with the business entity. Currently there is no option to support this and everytime the customer has to check out following the same process. Can a option be given to reorder from the past orders?
                                                                                                  • Coupons are not being accepted. (Saying expired)

                                                                                                    I am putting together a coupon for our company's store. When I went to test it, I received a notification that the coupon is expired. (the date range should be fine though) I've tested different options for the coupon along with one of my other colleagues
                                                                                                  • Issues with Agent Forwarding Card in Zobot

                                                                                                    I implemented an Agent Forwarding Card in a Zobot that I created. There are a few issues with the way the card functions in an actual chat. The way it is designed right now is not easy to use and is not intuitive. Here are a few of the issues I have with
                                                                                                  • Drop Shipping

                                                                                                    We have manufacturers drop ship all of the items in our ecommerce store. that means that each item needs to have its own unique zip code to acquire real time shipping rates from that zip code. and then the manufacturer of that item gets an automatic email
                                                                                                  • apple pay

                                                                                                    if a customer is accessing via an iphone etc and we are taking payments via stripe would they be able to use apple pay?
                                                                                                  • is Zoho eCommerce dead?

                                                                                                    Hello, we have Zoho eCommerce in our Zoho One Suite. After a year's break, we took a look at Zoho eCommerce this week. Very little has been developed. The normal eCommerce 2023 standard features are missing. Ok, Zoho eCommerce cannot be compared with
                                                                                                  • Issue with Cart API Implementation - Products Not Being Added to Cart

                                                                                                    I am writing to report an issue I'm experiencing with the Cart API implementation. I have tried multiple approaches to add products to a customer's cart programmatically, but I'm encountering difficulties. API Request Approach I am making a POST request
                                                                                                  • Pre-orders at Zoho Commerce

                                                                                                    We plan to have regular producs that are avaliable for purchase now and we plan to have products that will be avaliable in 2-4 weeks. How we can take the pre-orders for these products? We need to take the money for the product now, but the delivery will
                                                                                                  • wishlist

                                                                                                    I need to know where to find the wishlist function in Zoho Commerce
                                                                                                  • single user access to the CRM suits

                                                                                                    I am currently using Zoho CRM Plus, where the pricing for a single user is ₹3,500 INR, and it includes access to multiple applications. However, I would like to add an additional user but restrict their access to only two specific applications within
                                                                                                  • Zoho Commerce / Zoho Inventory Integration

                                                                                                    How can I remove products in my Zoho Commerce products section? I have a big list of products here that are linked to our Zoho Inventory and some are published on our site and some aren't, but I'm wondering how we can remove these products from this list
                                                                                                  • Pinterest's "Claim website" requirement

                                                                                                    Hi, I need to get Pinterest and my Zoho website to shake-hands. For this, Pinterest needs me to 'claim my website' by adding a piece of HTML code to the <head> section. But is this the same as "Header and footer" sections in the settings? If yes, then
                                                                                                  • Agents can manage the Tasks on the go, now with Zoho Desk mobile app

                                                                                                     Hello, Everyone!    We are elated to announce one of our most asked for features 'Tasks' in the Zoho Desk app.  Agents can now create and associate tasks with a ticket and the tasks will be listed within the corresponding tickets.   Steps to access the tasks from the app:    1. Go to a particular ticket in the app. 2. Click the Tasks icon in the 'Related Information' section.  3. List of all the tasks will be displayed.    Refer to the screenshots (Android & iOS) attached below for your better understanding:
                                                                                                  • Quickly delete items in email builder?

                                                                                                    When deleting items in the email builder, it requires two clicks: one to hit the trash icon on the item, and then another click to confirm the delete. Is there anyway to skip the confirm deletion? Some kind of hot key like the Command button on the mac
                                                                                                  • How to Customize the Member Portal Login Page?

                                                                                                    Hi everyone, I am currently using the default member portal login page for Zoho Commerce, but I feel it looks quite plain and doesn’t align well with my brand's style. I would like to make it more visually appealing, possibly by: Adding custom colors
                                                                                                  • Introducing WhatsApp Marketing with Zoho Marketing Automation

                                                                                                    Dear Marketers, In the world of marketing, personalizing engagements with customers is often exhaustive but—thanks to WhatsApp—not exactly mysterious. WhatsApp has evolved from a simple messaging platform to a sophisticated tool for sending out marketing
                                                                                                  • Separating Inventory for Online Shop and Other Customers in Zoho Commerce & Inventory

                                                                                                    Hello everyone, We are using Zoho Commerce and are facing a challenge in managing our stock for different types of customers. Specifically, we want to ensure that our online shop pulls stock only from a specific warehouse, while other customers (e.g.,
                                                                                                  • Use of External Email Services

                                                                                                    Would like the ability to use an external SMTP service to send emails campaigns in Marketing Automation.  Services like SendGrid, Maligun Amazon SES, etc
                                                                                                  • The difference between Zoho Marketing Automation and Zoho Campaigns

                                                                                                    Greetings Marketers! This post aims to differentiate between Zoho Marketing Automation and Zoho Campaigns. By the time you get to the end of the post, you will be able to choose a product that objectively suits you.What is Zoho Marketing Automation? A
                                                                                                  • Next Level - Turn this product into an Adobe Experience Manager Competitor

                                                                                                    I think Zoho Marketing Automation can best differentiate itself from the Zoho Campaigns and other Marketing related products better by tying the entire suite of marketing tools together not only in a viewable instance but in terms of developing internal
                                                                                                  • Quickly review loan applications for maximum efficiency | Kiosk Studio Session #5

                                                                                                    Hello everyone, Let's take a lending institution as the context for this session. A lot of people apply for loans, and the process of reviewing these applications can be labor-intensive and time-consuming. This process is handled by loan officers and
                                                                                                  • How do you do ticket add ons in Backstage?

                                                                                                    Hi Everyone, If you wanted to have general admin tickets and allow for add ons, like camping, or car or Carbon offset. What would you do? Peace Robin
                                                                                                  • can change deal colors in bigin?

                                                                                                    can be super useful if we can change colors deals process  any way to do it?
                                                                                                  • Enrich your CRM data and keep them updated

                                                                                                    You spend a lot of your time and efforts in generating quality leads for your business. While generating leads is a challenge in itself, the real deal begins when sales reps try to nurture these leads and convert them as customers. So how equipped is your sales team with information about your leads matters a lot.  For example, you might be using webforms to generate leads and collect customer information from your website. The lesser your webform fields are, the more your sign-ups right? From optimizing
                                                                                                  • Zoho Finance Workshop 2025 is Happening Now!

                                                                                                    Hello everyone! 👋 We’re thrilled to announce that the Zoho Finance Workshop 2025 has officially started, and we've already wrapped up the event in Chennai, our home ground! After an amazing session, we're geared up to visit more cities in India and take
                                                                                                  • Next Page