Convert SETSELECTIONFILTER to SETFILTER

If you want to print more than one document in a document list at one stroke – e.g. sales invoices – you would select 2 or more records and then start printing.

But, … in the request page only the last selected document no. or, also possible, no number is set.

Internally in most cases a setselectionfilter command is applied to get the selected records. But whats going on, when selecting the records? each record is marked. With setselectionfilter we can filter the selected record for the setfilter expression.
To print all selected records in one stroke you can do following. Add a new action to the action list of the list page and add following code to the new action trigger:

// local variablesSalesInvHeader | Record | Sales Invoice HeadernoFilter | Text// the code - OnAction()CurrPage.SETSELECTIONFILTER(SalesInvHeader); // fetch the marks// internally property Marked is set to true at the selected records// the loop will fetch only these recordsIF SalesInvHeader.FINDFIRST THEN BEGIN  REPEATIF noFilter  '' THEN  noFilter := noFilter + '|';noFilter := noFilter + SalesInvHeader."No."; // create filter expr.  UNTIL SalesInvHeader.NEXT = 0;  CLEAR(SalesInvHeader);  SalesInvHeader.SETFILTER("No.",noFilter); // create the filterEND;REPORT.RUNMODAL(206,TRUE,FALSE,SalesInvHeader);

As result we get:

Cheers

One thought on “Convert SETSELECTIONFILTER to SETFILTER

Leave a comment