Get all invoice from another set

Hi Guys,

I want to show all unblocked customer printed invoice, i did this code in my page, however I only get all invoices from one unblocked customer, how should I get all printed sales invoices from a list of Customer? Am I do this alright to use Rec:=xxxx?

Cust.RESET;
Cust.SETRANGE(Cust.Blocked,Cust.Blocked::" ");

IF Cust.FIND(’-’) THEN BEGIN
SalesInvoiceHead2.RESET;
SalesInvoiceHead2.SETFILTER(“No. Printed”,’>%1’,0);
SalesInvoiceHead2.SETRANGE(“Sell-to Customer No.”,Cust.“No.”);
END;

IF SalesInvoiceHead2.FINDSET
Rec := SalesInvoiceHead2;

you need to REPEAT the cust loop

Cust.RESET;
Cust.SETRANGE(Cust.Blocked,Cust.Blocked::" ");

SalesInvoiceHead2.RESET;
SalesInvoiceHead2.SETFILTER(“No. Printed”,’>%1’,0);
IF Cust.FIND(’-’) THEN BEGIN
REPEAT
SalesInvoiceHead2.SETRANGE(“Sell-to Customer No.”,Cust.“No.”);
UNTIL Cust.NEXT = 0;
END;
Rec.COPY(SalesInvoiceHead2);
CurrPage.UPDATE(FALSE);

I modified the code and add the REPEAT LOOP however after excute the page set a filter on it and only show the last customer invoice.
where am I getting wrong with this program ?

Hi BB,
Exactly what is it that you want to repeat?
Right now the only code you are repeating is the SETRANGE? Not really sure that helps you.

It looks like you’re trying to do something different. Like looping through customers and then their sales headers. That could work, then you need to loop and either temporary mark the sales invoices or insert them to a temporary list and show that list.

But please let us know where you have this code?

Hi Erik,

Thanks for your reply, I am trying to write a customized page with an Action button to show all unblocked customer invoice with printed qty > 1 in a list. I am writting the code by myself (I am new in Nav C/AL code).
What is the best practise for this simply task?

Kindly regards