
Hi everyone,
Can you please update how we can use No. of copies feature in D365 BC using AL.
You have a dataitem for the integer table which is controlled by a variable. Code for the triggers on this dataitem, generally called copyloop:
OnAfterGetRecord()
begin
if Number > 1 then begin
CopyText := FormatDocument.GetCOPYText;
OutputNo += 1;
end;
end;
OnPreDataItem()
begin
NoOfLoops := Abs(NoOfCopies) + 1;
if NoOfLoops <= 0 then
NoOfLoops := 1;
CopyText := '';
SetRange(Number, 1, NoOfLoops);
OutputNo := 1;
end;
}
Note the setrange on Number. That stops an infinite loop the noofcopies integer variable needs to be on the request page
requestpage
{
SaveValues = true;
layout
{
area(content)
{
group(Options)
{
Caption = 'Options';
field(NoOfCopies; NoOfCopies)