Get selected records from a lookup/modal page
Ramonchu
Member Posts: 31
Hello.
I'm creating a page with an action button to open a window that shows posted shipment headers to pick some of them and insert them in a table.
The structure is: page->action button->run codeuntit->call to a page that shows headers->pick some lines->call back to codeunit-> call to insert lines.
I have the problem in the callback from modal page (headers) to codeunit, because in the codeunit I get all the rows, not the selected rows.
In my headers page I have:
CurrPage.SETSELECTIONFILTER(Rec);
MESSAGE('Qty: ' + FORMAT(Rec.COUNT)); // I get the right number of selected rows for example 2
MyCodeunit.CreateLines(Rec);
After, in MyCodeunit, in CreateLines funtcion, I receive all the lines, not the selected lines. If I check the COUNT again it counts all the lines. I thought Rec sends to the codeunit only selected lines. Is this correct? What can be the problem?
Page source table is "Sales Shipment Header". Codeunit variable is a record of "Sales Shipment Header".
All the best!
I'm creating a page with an action button to open a window that shows posted shipment headers to pick some of them and insert them in a table.
The structure is: page->action button->run codeuntit->call to a page that shows headers->pick some lines->call back to codeunit-> call to insert lines.
I have the problem in the callback from modal page (headers) to codeunit, because in the codeunit I get all the rows, not the selected rows.
In my headers page I have:
CurrPage.SETSELECTIONFILTER(Rec);
MESSAGE('Qty: ' + FORMAT(Rec.COUNT)); // I get the right number of selected rows for example 2
MyCodeunit.CreateLines(Rec);
After, in MyCodeunit, in CreateLines funtcion, I receive all the lines, not the selected lines. If I check the COUNT again it counts all the lines. I thought Rec sends to the codeunit only selected lines. Is this correct? What can be the problem?
Page source table is "Sales Shipment Header". Codeunit variable is a record of "Sales Shipment Header".
All the best!
0
Best Answer
-
Hi,
I have never actually tried this, but I do not see any reason why this would not work. Please check for any CLEAR, CLEARALL, and RESET that might purge the filter set by SETSELECTIONFILTER. Also make sure you do not mess with MARKEDONLY. SETSELECTIONFILTER sets this as it needs to be.
And finally, make sure you pass the record using VAR parameters wherever you pass Rec on into any functions.6
Answers
-
Hi,
I have never actually tried this, but I do not see any reason why this would not work. Please check for any CLEAR, CLEARALL, and RESET that might purge the filter set by SETSELECTIONFILTER. Also make sure you do not mess with MARKEDONLY. SETSELECTIONFILTER sets this as it needs to be.
And finally, make sure you pass the record using VAR parameters wherever you pass Rec on into any functions.6 -
Thanks for the answer Vaprog but still doesn't work. I took the idea from Codeunit 64 and Page 5708.
I've created a test codeunit and page to check where is the problem:
Codeunit 50005 "Cod. Customer Test"
Page 50000 "Customer Test" -> works with Customer table.
Here is the code:
Page:
OnQueryClosePage(CloseAction : Action None) : Boolean
If CloseAction IN [ACTION::OK,ACTION::LookupOK] THEN
CreateLines; // Function in the page
CreateLines()
CurrPage.SETSELECTIONFILTER(Rec);
MESSAGE('Total recs: ' + FORMAT(Rec.COUNT));
CodeunitCustomerTest.CreateLines(Rec); // type Codeunit subtype 50005
Codeunit:
OnRun()
CustomersWindow.LOOKUPMODE := TRUE; // type page subtype 50000
IF CustomersWindow.RUNMODAL <> ACTION::Cancel THEN;
CreateLines(Customers2 : Record Customer)
MESSAGE('Qty: ' + FORMAT(Customers2.COUNT));
Ok, after I run the codeunit, it opens page 50000 listing my customers. I select for example 3. The message in the Page shows Qty=3, but after the call to CreateLines in the codeunit, the message shows que quantity of customers, for example 650.
I don't know why the codeunit call does not send the selected recs. Is it a VAR parameter problem? Any ideas?
0 -
Solved!!
Pffffffffff, the problem was the VAR parameter as you told me. I had not clicked VAR in the local definition of the function parameter!
Thank you!
0 -
CreateLines(VAR Customers2 : Record Customer) MESSAGE('Qty: ' + FORMAT(Customers2.COUNT));
The VAR should do the trick..Austrian NAV/BC Dev0 -
[Topic moved from 'NAV/Navision Classic Client' forum to 'NAV Three Tier' forum]
Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.7K 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
- 326 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
