Question about OnLookup Form

Hi to all, I'm very fresh as navision developer and I'm facing the following task.
In my Form I have a field called Item. No., and another field called Packing List No. that is a lookup field.
Each Packing List contains a list of Packing List Item and each Item is related to a specific Item No.
I'd like to prefilter the lookup field displaying only the Packing Lists containing the Item specified in Item No. field.
I'm trying to do the work in the OnLookup trigger of the Packing List No. field but without success, can someone suggest me a way to accomplish this task.

Thank you in advance for your help.
Fabrizio

Best Answer

Answers

  • postsauravpostsaurav Member Posts: 708
    HI,

    Let us know what you tried.

    Just a Tip - While Calling Lookup of the Table / Form, Pass A Record of Table with Filter of Item No.

    Just wanted to make you think, if still any confusion let us know the code that you are trying.

    Thanks & Regards,
    Saurav Dhyani

    Do you Know this About NAV?


    Connect - Twitter | Facebook | Google + | YouTube

    Follow - Blog | Facebook Page | Google + Page
  • fabriziocfabrizioc Member Posts: 31
    Dear postsaurav, thank you for your help, I've tried with a similar approach, here you can find the code of the OnLookup form trigger


    CLEAR(MyPackingListLookupForm);
    MyPackingListLine.SETFILTER("Item No.","Item No.");
    IF MyPackingListLine.FINDSET THEN BEGIN
    MyPackingList.SETFILTER("Packing List No.",MyPackingListLine."Packing List No.");
    END;
    IF MyPackingList.FINDSET THEN BEGIN
    MyPackingListLookupForm.SETTABLEVIEW(MyPackingList);
    MyPackingListLookupForm.RUNMODAL;
    END;

    WHERE
    MyPackingListLookupForm is a variable of type Form Subtype Packing List - List
    MyPackingList is a variable of type Record Subtype Packing List Header
    MyPackingListLine is a variable of type Record Subtype Packing List Line

    Item No is a field of the form
    Now I'm able to retrieve the list of all PackingListLines with the Item. No. selected,
    PackingListLines contains several Records I need to set the second FINDSET on MyPackingList with all the Packing List No. values retrieved in the step before.

    Unfortunately only the last valus seems to be maintained by SetFilter.
    Could you suggest me a way to perform this action ?

    Thank you again for your precious help.
    Best regards
    Fabrizio
  • fabriziocfabrizioc Member Posts: 31
    Thank you Wisa123 it's almost perfect, just a final but perhaps not mandatory request, is possible to UNMARK the selected records once the filter has been applied ? If yes, how ?

    Thanks a lot for your help
    Fabrizio
  • Wisa123Wisa123 Member Posts: 308
    MyPackingList.CLEARMARKS should do the trick (below tableview, before page.runmodal)

    Regards, Wisa
    Austrian NAV/BC Dev
  • fabriziocfabrizioc Member Posts: 31
    Thank you Wisa, I've tried but it seems not to work.....this is my current code:


    IF NOT MyPackingList.ISEMPTY THEN BEGIN
    MyPackingListLookupForm.SETTABLEVIEW(MyPackingList);
    MyPackingList.CLEARMARKS;
    MyPackingListLookupForm.RUNMODAL;
    END;

    Thank you again for your help.

    Fabrizio
Sign In or Register to comment.