web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Dynamics 365 Community / Blogs / Franz Kalchmair Blog / Convert SETSELECTIONFILTER ...

Convert SETSELECTIONFILTER to SETFILTER

keoma Profile Picture keoma 32,729

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
<Action1100022000> - 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


Filed under: c/al, nav 2009, nav 2013, nav functions Tagged: c/al, filter, nav 2009, nav 2013, print

Comments

*This post is locked for comments

  • Community Member Profile Picture Community Member
    Posted at
    Introduction: I have been working in NAV/BC for a couple of years to master the craft and to some extent all of us are successful. But a single scenario/ user error/misunderstanding can create a big question mark. This blog is mainly divided into two
  • Community Member Profile Picture Community Member
    Posted at
    Introduction: I have been working in NAV/BC for a couple of years to master the craft and to some extent all of us are successful. But a single scenario/ user error/misunderstanding can create a big question...