SETSELECTIONFILTER in Actions

MarkKs
Member Posts: 12
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.
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
Best Answer
-
Action code:
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;
5
Answers
-
Action code:
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;
5 -
Thank you! Just a question when I put the record VAR as parameter in the function, I can detect which lines the user selected by the primary key of the table right? Before I decide to make the main question, I put as parameter, the primary key of the table instead of the record itself. Can you explain me the difference between creating a function with a VAR parameter and with a non-VAR parameter?0
-
Thank you! Just a question when I put the record VAR as parameter in the function, I can detect which lines the user selected by the primary key of the table right?Before I decide to make the main question, I put as parameter, the primary key of the table instead of the record itself.Can you explain me the difference between creating a function with a VAR parameter and with a non-VAR parameter?
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.
0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions