RecordRef / FieldRef

DesmedtS
Member Posts: 53
Hello,
I wrote ethe following code :
RecRef : RecordRef
FldRef : FieldRef
RecRef.OPEN(27);
FldRef := RecRef.FIELD(1); // Item."No."
FldRef.SETRANGE('70000');
RecRef.FIND('-');
FOR i := 1 TO RecRef.FIELDCOUNT DO BEGIN
FldRef := RecRef.FIELDINDEX(i);
CASE FldRef.NAME OF // Or you can use a case on FldRef.NUMBER
'description': MESSAGE('%1 is2.',FldRef.CAPTION,FldRef.VALUE);
'Unit Cost': MESSAGE('%1 is %2.',FldRef.CAPTION,FldRef.VALUE);
END;
END;
The following problem is this line of code :
FldRef := RecRef.FIELD(1); // Item."No."
FldRef.SETRANGE('70000');
The SETRANGE is a value that filters only on field no.
The above code is in a loop so (repeat of a setup table), for example
the first time i loop, I want to filter on Item no.
the second time, i want to filter on unit cost. of a specific item where my record is positioned at.
The table No. and the field no. is in a setup table of which value a have to get.
How can i make this variable ?
So for further example :
I have the right record and then i look in my setup table where there is always a table No. and a Field No., and
FldRef := RecRef.FIELD(xxx); // xxx must be the field no. of the
table which is in the setup table
FldRef.SETRANGE('xxx'); // xxx lust ve the value of the table
No. and the field No.
Thx a lot
Steve
I wrote ethe following code :
RecRef : RecordRef
FldRef : FieldRef
RecRef.OPEN(27);
FldRef := RecRef.FIELD(1); // Item."No."
FldRef.SETRANGE('70000');
RecRef.FIND('-');
FOR i := 1 TO RecRef.FIELDCOUNT DO BEGIN
FldRef := RecRef.FIELDINDEX(i);
CASE FldRef.NAME OF // Or you can use a case on FldRef.NUMBER
'description': MESSAGE('%1 is2.',FldRef.CAPTION,FldRef.VALUE);
'Unit Cost': MESSAGE('%1 is %2.',FldRef.CAPTION,FldRef.VALUE);
END;
END;
The following problem is this line of code :
FldRef := RecRef.FIELD(1); // Item."No."
FldRef.SETRANGE('70000');
The SETRANGE is a value that filters only on field no.
The above code is in a loop so (repeat of a setup table), for example
the first time i loop, I want to filter on Item no.
the second time, i want to filter on unit cost. of a specific item where my record is positioned at.
The table No. and the field no. is in a setup table of which value a have to get.
How can i make this variable ?
So for further example :
I have the right record and then i look in my setup table where there is always a table No. and a Field No., and
FldRef := RecRef.FIELD(xxx); // xxx must be the field no. of the
table which is in the setup table
FldRef.SETRANGE('xxx'); // xxx lust ve the value of the table
No. and the field No.
Thx a lot
Steve
-1
Comments
-
Steve,
did you take a look at my record ref sample?
http://www.mibuso.com/dlinfo.asp?FileID=276
Maybe the answer is in there somewhere?"Real programmers don't comment their code.
If it was hard to write, it should be hard to understand."0 -
btw,
You will need a table inwhich you store table and field nos.filter.setrange(tableno, 27); if not filter.find('-') then exit; repeat fieldref := recref.field(filter.field); fieldref.setrange(filter.filtervalue); until filter.next = 0; if not fieldref.find('-') then exit; message('a record was found!');
"Real programmers don't comment their code.
If it was hard to write, it should be hard to understand."0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions