SetSelectionFilter problem

I use SetSelectionFilter to take the filter of selection in a rec1. Then I pass this rec1 in a function. This function uses a local variable rec2 and copy the rec1. I use this local variable in a report.runmodal. I select just one record. The rec1 variable has rec1.count=1 The rec2 variable has a count of all records. The same operation exists when i push the print button in a Posted Sales Invoice form. Is this a bug ? Is this form designed to print only the selected record ?

Did you pass rec1 as a VAR parameter to the function? I have made the experience (and did not find any documentation on this issue…) that filters attached to records are only passed to a function when the record is passed as a VAR parameter. Otherwise, all filters are zonked.

By copying rec1 to rec2 you DON’T copy filters ! this will only copy the data from rec1 to rec2

quote:


Originally posted by iammicky
By copying rec1 to rec2 you DON’T copy filters ! this will only copy the data from rec1 to rec2


From the C/AL reference guide, COPY function:

quote:


Use this function to copy a record from a C/SIDE table. All filters, marks, and keys are included in the copy.


OTOH, if you refer to a simple assignment of rec2 to rec1, then you are right.

apparently, SETSELECTIONFILTER is then not a ‘real’ filter, because that gets lost when you do COPY…

Let’s get some things straight:

  • Filters don’t get copied when using assignments (Rec1 := Rec).
  • Filters get copied when using COPY.
  • Filters only get passed when using VAR parameters (by reference). This is not a copy - you’re in fact working on the same variable.
  • A value passed parameter is in essence an assignment, and thus filters are NOT copied.
  • SETSELECTIONFILTER is a “real” filter (MARKEDONLY) and it does get copied (like all other filters) when using COPY.
    Check this thread http://www.navision.net/forum/topic.asp?TOPIC_ID=8841