Options

Get selected records from a lookup/modal page

RamonchuRamonchu 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!

Best Answer

Answers

  • Options
    RamonchuRamonchu Member Posts: 31
    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?

  • Options
    RamonchuRamonchu Member Posts: 31
    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!
  • Options
    Wisa123Wisa123 Member Posts: 308
    edited 2016-02-26
    CreateLines(VAR Customers2 : Record Customer)
    MESSAGE('Qty: ' + FORMAT(Customers2.COUNT));
    

    The VAR should do the trick..
    Austrian NAV/BC Dev
  • Options
    krikikriki Member, Moderator Posts: 9,089
    [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!


Sign In or Register to comment.