How to add new row immediately below the current row and not in the last.

How to add new row immediately below the current row and not in the last.

My current script is adding new row at the end of the subform but I want to add row next to or just below the current row. Can anyone help?

Current Script:
// Extract the numeric quantity from the 'Quantity added' string
addedQtyText = row.Quantity_Added.toString();
addedQtyNum = addedQtyText.replaceAll("[^0-9.]","");
// Remove all non-numeric characters, assuming a period for decimals
// Convert to number, with error handling for empty or invalid input
try 
{
addedQty = addedQtyNum.toDecimal();
}
catch (e)
{
addedQty = 0;
// Set a default or handle the error as appropriate
}
// Extract the numeric quantity from the 'Quantity to add' string
//toAddQtyText = input.Ingredients.Quantity_to_add.toString();
toAddQtyText = row.Quantity_to_add.toString();
toAddQtyNum = toAddQtyText.replaceAll("[^0-9.]","");
// Convert to number, with error handling
try 
{
toAddQty = toAddQtyNum.toDecimal();
}
catch (e)
{
toAddQty = 0;
// Set a default or handle the error as appropriate
}
// Validation for excess quantity
if(addedQty > toAddQty)
{
alert "Please check the quantity added, as it is more than required. कृपया जोड़ी गई मात्रा की जांच करें, क्योंकि यह आवश्यकता से अधिक है।";
return;
// Stop execution if the added quantity is too much
}
// Calculate the difference percentage
difference = toAddQty - addedQty;
percentageDiff = difference / toAddQty * 100;
// Check if the difference is greater than 0.5%
if(percentageDiff > 0.5)
{
// Add a new row with the same ingredient name and the difference as 'Quantity to add'
newSubformRow = Production_Batch.Ingredients();
newSubformRow.Ingredients=row.Ingredients;
newSubformRow.Quantity_to_add=difference.toString();
// Create a collection to hold the new row
rowsCollection = Collection();
rowsCollection.insert(newSubformRow);
// Use 'insert' to add the collection to the subform
input.Ingredients.insert(rowsCollection);
// Prompt for the remaining quantity
alert "Enter the remaining quantity in the next field and scan the new batch. अगले फील्ड में शेष मात्रा दर्ज करें और नए बैच को स्कैन करें।";
}

    Zoho Desk Resources

    • Desk Community Learning Series


    • Digest


    • Functions


    • Meetups


    • Kbase


    • Resources


    • Glossary


    • Desk Marketplace


    • MVP Corner


    • Word of the Day


      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 Campaigns 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 コンテンツ




                              ご検討中の方