Get value by FieldNo.

santiagonav
Member Posts: 6
Hi, sorry for my English, that's not my language. I'll try to explain as best as possible.
I'm trying to retrieve a value from current record (Rec), but I need to recover the value of a particular field (this information I get from another table, id field and name field).
I tried to do through RecRef and Field Ref, but I can not position the cursor on the desired record (Rec). I have the feeling that there is an easier way.
I hope I explained well. Any help would be welcome.
Regards.
I'm trying to retrieve a value from current record (Rec), but I need to recover the value of a particular field (this information I get from another table, id field and name field).
I tried to do through RecRef and Field Ref, but I can not position the cursor on the desired record (Rec). I have the feeling that there is an easier way.
I hope I explained well. Any help would be welcome.
Regards.
0
Comments
-
If you have only the field no., then you have to do it by recordref. Check out codeunit 423 (Change Log Management) for details how to user references.0
-
Solved using SETTABLE in RecordRef.
recRF.OPEN(recObjet.ID,FALSE);
recRF.SETTABLE(Rec);
recRF.FINDFIRST;
fldRef := recRF.FIELD(3); //<---Set the Field Number
MESSAGE(FORMAT(fldRef.VALUE));0 -
I thought it worked, but it is not.
When I called from a Card Form (without filters), I am getting data from the first record.
RecObject.ID is the value of the current table.0 -
why do you want to do this?
why do you use recordref and fieldref instead of declaring a table variable and to a simplemessage(format(mytable.myfield));
:?:
moreover, you should use GETPOSITION and SETPOSITION (use NAV online help for more info about these functions) to achieve what you need.
if you do a FINDFIRST without filters like you did, what can you expect?the first record in the table, i guess!0 -
Hi, thanks for spending your time to help me.
I can not create a simple variable, because the table I find out at runtime.
I will investigate the functions and setPosition getPosition (never had used before.)
With FindFirst, I thought that would be placed in the current record, but I was wrong.
Thank you0 -
You have a record as your Source and want to get the value of a field, right?
RecRef.GETTABLE(Record);
FRef := RecRef.FIELD(FieldNo);
There's your FRef.VALUE, no need to FIND the record ...
On a sidenote: FINDFIRST will move to the first record. If you have the PK-Values set (e.g. by SETPOSITION) you can use FIND('=') to fetch the record.
Cheers,
mkb0
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