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;