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.

sc1

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

sc2

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:

sc3

// local variables
SalesInvHeader | Record | Sales Invoice Header
noFilter | 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 records
IF SalesInvHeader.FINDFIRST THEN BEGIN
  REPEAT
    IF noFilter  '' THEN
      noFilter := noFilter + '|';
    noFilter := noFilter + SalesInvHeader."No."; // create filter expr.
  UNTIL SalesInvHeader.NEXT = 0;
  CLEAR(SalesInvHeader);
  SalesInvHeader.SETFILTER("No.",noFilter); // create the filter
END;
REPORT.RUNMODAL(206,TRUE,FALSE,SalesInvHeader);

As result we get:

sc4

Cheers

Advertisements

One thought on “Convert SETSELECTIONFILTER to SETFILTER

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s