So, It was asked to me as learning exercise, to create an action in a page to pick a boolean Field based on the selected lines, so for exemple:
3 lines selected = Boolean Field of each line picked.
I created the code of this action in a codeunit to select the lines and fill the boolean field, but only fills the boolean field of the last line, I have 3 selected and the last one gets the boolean field filled. The action code only have 2 lines
CurrPage.SETSELECTIONFILTER(Rec); - This was supposed to make the function below to work on more than 1 line selected.
CUTest.PickLines(No.); - No. is the primary key of the table as parameter to know which lines are selected
Help me understand how should I use SETSELECTIONFILTER in this case and if I have to leave the SETSELECTIONFILTER in the page or in the codeunit with all the code.
P.S - I believe there's no need of showing the CU code here, but If you need to see it just ask.
0
Answers
SETSELECTIONFILTER(Rec);
CUTest.PickLines(Rec);
Codeunit code:
PickLines(VAR <Your record>: Record(<Your Table>)
IF <Your record>.FINDSET THEN
REPEAT
... your code here
UNTIL <Your record>.NEXT = 0;
With non VAR parameters of type Record, only the field values are passed; exactly the same happens as in an ordinary assignment of record variables (e.g. RecA := RecB;) Therefore, no filters are propagated and you loose the state of the Temporary property. So, if you need any of those, you must use a VAR parameter.