Announcements
So I have a table and I want to insert and remove the records from another table based on the condition.
trigger OnOpenPage() begin insertData(); // Rec.Reset(); // if (Rec.FindLast() = true) then // exit // else // insertData(); end; local procedure insertData() var uerBatchTable: Record uerDistributionBatchTable; begin uerBatchTable.Reset(); uerBatchTable.FindSet(); repeat begin if (uerBatchTable.Stop = false) then begin Rec.Init(); Rec.RowNo := Rec.RowNo 1; Rec.uerDistributionPoolBatchID := uerBatchTable.uerDistributionPoolBatchID; Rec.uerDistributionPoolID := uerBatchTable.uerDistributionPoolID; Rec.uerDistributionDate := uerBatchTable.uerDistributionDate; Rec.uerDescription := uerBatchTable.uerDescription; Rec.uerAmountToAllocate := 0; Rec.uerOrigAmountToAllocate := uerBatchTable.uerDistributionAmt; Rec.uerPreviousAmountToAllocate := 0; Rec.uerAmountNotDistributed := (Rec.uerOrigAmountToAllocate - 0); Rec.Insert(true); end; end; until uerBatchTable.Next() = 0;
The first time when I open the page it inserts the records after re-loading again or modifying the condition it gives an error.
Kindly help.
Regards
Hi
my counter would work if your page was temporary:
so either set the page property TEMPORARY=TRUE
o
check which row line is the last one you inserted in the table:
rec.findlast;
counter:=Rec.RowNo;
if (uerBatchTable.Stop = false) then begin
counter += 1;
Rec.Init();
Rec.RowNo := counter
DAniele
Hi, if you don't use a temporary table, I think you should add a condition. You must first determine whether this record already exists in your table. If it does not exist, insert it, and skip it if it exists.
Hope this helps as well
Thanks.
ZHU
Hi,
Use Variable instead of REC and then find the last entry no and then increment that last entry number and then insert the recod.
Regards
Amit Sharma
Hey Daniele Incalza,
Thank you for replying...
No, my table is not TmpTable and your separate variable for count is not working. As I have tried both ways..
OnOpenPage trigger first emptying the table and then inserting the data works fine but I want to solve it with the condition.
Regards.
Ciao
l'errore è il seguente;
quando fai la INIT del Rec, la tua Rec.RowNo viene resettata a 0. e quindi viene inserita sempre 1.
provate così, assicurandovi che la PAge sia sempre Temporary=TRUE
trigger OnOpenPage()
begin
insertData();
// Rec.Reset();
// if (Rec.FindLast() = true) then
// exit
// else
// insertData();
end;
local procedure insertData()
var
uerBatchTable: Record uerDistributionBatchTable;
counter: integer;
begin
uerBatchTable.Reset();
uerBatchTable.FindSet();
repeat begin
if (uerBatchTable.Stop = false) then begin
counter += 1;
Rec.Init();
Rec.RowNo := counter;
Rec.uerDistributionPoolBatchID := uerBatchTable.uerDistributionPoolBatchID;
Rec.uerDistributionPoolID := uerBatchTable.uerDistributionPoolID;
Rec.uerDistributionDate := uerBatchTable.uerDistributionDate;
Rec.uerDescription := uerBatchTable.uerDescription;
Rec.uerAmountToAllocate := 0;
Rec.uerOrigAmountToAllocate := uerBatchTable.uerDistributionAmt;
Rec.uerPreviousAmountToAllocate := 0;
Rec.uerAmountNotDistributed := (Rec.uerOrigAmountToAllocate - 0);
Rec.Insert(true);
end;
end;
until uerBatchTable.Next() = 0;
BYe
DAniele
check my answer if it solves your problem
HI
the page is Temporary=YES?
Verify it
check my answer if it solves your problem
DAniele
André Arnaud de Cal...
293,289
Super User 2025 Season 1
Martin Dráb
232,068
Most Valuable Professional
nmaenpaa
101,156
Moderator