OnLookup Filter

Kc_NirvanaKc_Nirvana Member Posts: 146
Hi. This is my first post. I am a very noob in Navision and i need your help.
The Problem:
I have created a new table like which have type(Item,Fixed asset) and No. .
On the table relation of No. I put "IF (Type=CONST(Item)) Item ELSE IF (Type=CONST(Fixed Asset)) "Fixed Asset" WHERE (Requirement=CONST(Yes))" where requirement is a new boolean field.
When i do the lookupmode on the No., with type = Fixed Asset it goes to Fixed Asset List and only show the fixed assets which requirement = TRUE.
So far so good...
But if i click on the button Show All ( in Menu Navision where are the buttons list, right, left) it shows me all fixed assets.
How can i solve this?

Sorry about my english........
Junior Consultant & Developer in Dynamics NAV

"I'm worse at what I do best
And for this gift I feel blessed
Our little group has always been
And always will until the end"

Nirvana - Nevermind - Smells Like Teen Spirit

Comments

  • matttraxmatttrax Member Posts: 2,309
    That's just part of NAV. Filters can be removed...usually.

    If you don't want them to be able to remove the filters, look into FILTERGROUP functionality. You'll have to code your own lookups, though. I would just leave it as is unless you have a requirement that the user is not allowed to unfilter.
  • Kc_NirvanaKc_Nirvana Member Posts: 146
    Alright thanks......
    I've already had thought in that solution...

    In this code what am i doing wrong? because the value "No." does not change......... Im doing this on a table

    No. On lookup
    IF Type = Type::"Fixed Asset" THEN
      BEGIN
        FORM.ActivateLockFilter (My function which set and locks the record)
        FORM.LOOKUPMODE := TRUE;
        IF FORM.RUNMODAL =ACTION::LookupOK THEN BEGIN
         FORM.GETRECORD(MyRec)
         "No." := MyRec."No.";
        END;
        END;
    
    Junior Consultant & Developer in Dynamics NAV

    "I'm worse at what I do best
    And for this gift I feel blessed
    Our little group has always been
    And always will until the end"

    Nirvana - Nevermind - Smells Like Teen Spirit
  • ReinhardReinhard Member Posts: 249
    I'm not 100% sure from your code. In any case, I usually do it like this:
    No. - onLookup
    local variable fixedAsset
    {
      IF FORM.RUNMODAL(0,fixedAsset) = Action::lookupOk THEN
        VALIDATE("No.",fixedAsset."No.");
    }
    

    If you only want them to see certain Fixed Assets in the list, and you don't want to let them "Show All" then do something like this:
    No. - onLookup
    local variable fixedAsset
    {
      fixedAsset.FILTERGROUP(10);
      fixedAsset.SETRANGE(Requirement,TRUE);
      fixedAsset.FILTERGROUP(0);
      IF FORM.RUNMODAL(0,fixedAsset) = Action::lookupOk THEN
        VALIDATE("No.",fixedAsset."No.");
    }
    

    It's possible that you don't need to write any code at all though. Look at how table relations are set up on the "No." field on the Sales Line table.
  • Kc_NirvanaKc_Nirvana Member Posts: 146
    I've tried that but the problem is that I'm doing that code on the table and the "No." doesn't change. I can't put a value in the "No.".
    I tried on the form i create on the "No." onlookup trigger and it do fine, but on the table i can't pass the value from the fixed asset to "no."
    Junior Consultant & Developer in Dynamics NAV

    "I'm worse at what I do best
    And for this gift I feel blessed
    Our little group has always been
    And always will until the end"

    Nirvana - Nevermind - Smells Like Teen Spirit
Sign In or Register to comment.