How to get filters from page

IvonaKIvonaK Member Posts: 115
edited 2014-02-10 in NAV Three Tier
Is there any function in Nav 2009 R2 where I can get filters from page.

Thank a lot,

Comments

  • ReinhardReinhard Member Posts: 249
    You mean like Rec.GETFILTERS ?
  • IvonaKIvonaK Member Posts: 115
    Hi,
    I have a page like picture 1 and I want when insert new item in Table to get filter Type to be: Subgroup1 and Parent Code to be 500 (filters are marked with red ).

    Thanks,
  • geordiegeordie Member Posts: 655
    SETRANGE(Type,Type::Subgroup1);
    SETRANGE("Parent Code",500);
    

    To be added in OnInsertRecord trigger (or OnNewRecord, depending from your requirements details).
  • StLiStLi Member Posts: 83
    on the page:

    use Rec.GETFILTERS to see if any filters are set
    use Rec.GETFILTER(Type) to get the value that the record is currently filtered for. e.g. type::Subgroup1

    you can use it like this:

    otherinstanceofRec.init;
    otherinstanceofRec.type := rec.getfilter(type);
    otherinstanceofRec.insert;

    BUT: it's not guaranteed that the falue you get from "getfilter" is an actually valid value for the field... e.g. if the fitler is set to Type::subgroup1..Type::subgroup6 you will get an error.
  • thegunzothegunzo Member Posts: 274
    Take a look at the FILTERGROUP function.

    The page might be using FILTERGROUP 2, 3 or 4.

    the use

    FILTERGROUP(4);
    GETFILTER(Type);
    FILTERGROUP(0);

    Take a look here http://msdn.microsoft.com/en-us/library/dd338919.aspx
    ________________________________
    Gunnar Gestsson
    Microsoft Certified IT Professional
    Dynamics NAV MVP
    http://www.dynamics.is
    http://Objects4NAV.com
  • IvonaKIvonaK Member Posts: 115
    I have a table "Item Organizational Group", which has been done something like tree (picture 1)
    I have set LookUpFormId on table propertis

    On the table:Item I have add new field: Main Group, Subgroup 1, Subgroup 2 in which:

    Main Group: Table Relation: "Item Organizational Group" WHERE (Type = FILTER (Main Group))
    Subgroup 1: Table Relation: "Item Organizational Group" WHERE (Type = FILTER (Subgroup 1), Parent Code = FIELD (Main Group))
    Subgroup 2: Table Relation: "Item Organizational Group" WHERE (Type=FILTER(Subgroup 2),Parent Code=FIELD(Subgroup 1))

    When I click on LookUp on field Subgroup 1 (picture 2 )
    it works it give me the correct items (where Parent Code is Main Group and Type is Subgroup 1) , but when I click to create a new entry automatically entered in table:"Item Organizational Group" without any filters.

    I tried with gRecItemOrganGroup.GetFilters(Rec) and I put on Group Code-OnValide on page , but still doese't work, it give me Type=0.
    Also I tried with
    SETRANGE(Type,Type::"Subgroup 1");
    SETRANGE("Parent Code",'500'); onInsertRecord but doesn't work

    Any advice,
    Thanks
  • IvonaKIvonaK Member Posts: 115
    Hi,

    I add this code on NewRecord on page :

    EVALUATE(Type,GETFILTER(Type));
    EVALUATE("Parent Code",GETFILTER("Parent Code"));

    and It works now.

    Thanks,
Sign In or Register to comment.