Getting Duplicate record for only one value in label generator

Getting Duplicate record for only one value in label generator

Hello all, We have created a Label generator in Zoho Creator. The problem we are facing is a duplicate of a record for generating one label. If I have more than one label I won't get duplicate records. I want one record with one label to be generated.

the code we used is

// // col = Collection();
// // for each x in Label_data
// // {
// a = 0;
// b = input.Number_Of_Labels_per_Model;
// // b = 3
// c = if(b < 1,list(),"".leftpad(b - 1).toList(""));
// //c = {,,,};
// for each y in c
// {
// //initiating a row
// // row1 = No_of_Labels.SubForm();
// // row1.Shipped_by = x.Shipped_by;
// // row1.Consignee = x.Consignee;
// // row1.Model_ID = x.Model_ID;
// // row1.No_of_Pieces = x.No_of_Pieces;
// // row1.No_of_Packs = x.No_of_Packs;
// a = a+1;
// row1.Box_Number = a;
// col.insert(row1);
// }
// //}
// input.SubForm.clear();
// input.SubForm.insert(col);
//----------------------------------------
//_______________________
lis = leftpad("t",input.Number_Of_Labels_per_Model - 1).replaceall(" ",",t").toList();
a = 1;
//input.Serial_No = (counter + 1).tostring();
for each  rec in lis
{
last_add = Label_data[ID != 0] sort by Added_Time desc;
if(last_add.count() == 0)
{
sn = 1;
}
else
{
sn = ifnull(last_add.Serial_No,0) + 1;
}
insert into Label_data
[
Added_User=zoho.loginuser
Net_Weight_kg=input.Net_Weight_kg
Model_ID=input.Model_ID
No_of_Packs=input.No_of_Packs
Shipped_by=input.Shipped_by
Consignee=input.Consignee
No_of_Pieces=input.No_of_Pieces
Total_Boxs=input.Total_Boxs
Gross_Weight_kg=input.Gross_Weight_kg
Serial_No=sn
Box_Number=a
]
//counter = counter + 1;
}
input.Box_Number = a;
//___________________
last_add = Label_data[ID != 0] sort by Added_Time desc;
if(last_add.count() == 0)
{
sn1 = 1;
}
else
{
sn1 = last_add.Serial_No + 1;
}
input.Serial_No = sn1;


I have attached my output, I'm supposed to get one record. Instead, I'm getting an extra duplicate record. This is happening only for one record maintenance. if I give input >1, no duplicate record is coming.

kindly please help me to solve this issue. 

    Access your files securely from anywhere

        Zoho Developer Community




                                  Zoho Desk Resources

                                  • Desk Community Learning Series


                                  • Digest


                                  • Functions


                                  • Meetups


                                  • Kbase


                                  • Resources


                                  • Glossary


                                  • Desk Marketplace


                                  • MVP Corner


                                  • Word of the Day



                                      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 Campaigns 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