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 ).
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
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.
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
Comments
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,
To be added in OnInsertRecord trigger (or OnNewRecord, depending from your requirements details).
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.
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
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
I add this code on NewRecord on page :
EVALUATE(Type,GETFILTER(Type));
EVALUATE("Parent Code",GETFILTER("Parent Code"));
and It works now.
Thanks,