How to get whole record from lookup table, not only a field

merana
Member Posts: 41
Hello everyone, pls help
I have a table XYZ with option field.
The selected option determines which table will be use for lookup, and it works.
The problem is when i raise the lookup table, and select a record, a certain value is inserted in tbl XYZ in field2, and I would like automaticallly to fill one more field in tbl XYZ that appers in that lookup table.
Unfortunatly I don't have one primary key in the lookup tables - it's combination of two (one I am getting in field1, and the second I would like to have in field2).
Is it possible to solve this problem somehow, without adding unique primary key in the lookup tables.
TNX
I have a table XYZ with option field.
The selected option determines which table will be use for lookup, and it works.
The problem is when i raise the lookup table, and select a record, a certain value is inserted in tbl XYZ in field2, and I would like automaticallly to fill one more field in tbl XYZ that appers in that lookup table.
Unfortunatly I don't have one primary key in the lookup tables - it's combination of two (one I am getting in field1, and the second I would like to have in field2).
Is it possible to solve this problem somehow, without adding unique primary key in the lookup tables.
TNX
0
Comments
-
Hi,
Your explanation leaves much to my imagination... :-s
The update of your XYZ is done before, or after the lookup?
In general you could make a lookup routine of your onw in the XYZ record object and give the parameters you want.
If you call the lookup with a record parameter then you can get all the record the user has picked, by using the function GETRECORD.
I copy paste the code in the RUNMODAL (form) of the help:CLEAR(f) Form.XXX; // any user-defined function Form.SETTABLEVIEW(Rec); Form.SETRECORD(Rec); IF Form.RUNMODAL = Action::LookupOK THEN Form.GETRECORD(Rec)...
Does it cover you? If not, why don;t you explain better and with steps... :roll:0 -
I tried this before, but it's not working correctlly, but thank u.
When I do something like copy-paste of this code, I am getting message when I run table xyz ->lookup filed:'Tables are incomaptible'
I understand that...I think I don't need to settable view and rest.
But when I leave just this:IF f.RUNMODAL = Action::LookupOK THEN f.GETRECORD(Rec)...
It opens lookup table without OK and Cancel button, so I can't do anything.
Now, I try to explain more my problem....and sorry if I was too short in explaination
I have table (so callled XYZ) with few columns. One column is an option filed that provides user to select:
or Item category ,
or Product group ,
or Item ,
This column determines the table realation for the next column, whic is code type. So if user select
or Item category -> this column is lookup on Item Category
or Product group -> this column is lookup on Product Group
or Item -> this column is lookup on Item
One more column that is important is so called "Level above", which supposed to contain code of the level above..if record contains "Product group " in option field, and Code of the "Product group", this field shoud have code of the "Item Category", that this "Product group" belongs to.
So problem is: when user select something in lookup table, field with code for example "Product group code" is filled with selected value. But filed "Level Above" is empty!!!
I would like to filled it, in the moment when "Product group code" is filled.
IS it possible?
I need to get whole record from lookup table, but how?
I hope u can help me!0 -
Hello,
The incompatibility error is strange, it means that the Rec inside the GETRECORD is not the same rec with the Source table of the form.
Anyway, make a form variable to your lookup form, make arecord variable to your XYZ table, then:CLEAR(vLookupForm); vLookupForm.SETTABLEVIEW(vXYZrec); vLookupForm.SETRECORD(vXYZrec); vLookupForm.LOOKUPMODE(TRUE); IF vLookupForm.RUNMODAL = Action::LookupOK THEN vLookupForm.GETRECORD(vXYZrec);
And now in the vXYZrec variable you have the record the user picked on the lookup form.
The function LOOKUPMODE(TRUE) makes the OK and Cancel buttons visible on the form.
If this don't cover you, then you could make a few variables on your form and set them when the user picks something, and make a function in the form that gets some parameters (with var checked) and puts in those parameters the values that have been saved during the picking of the user. i.e.IF vLookupForm.RUNMODAL = Action::LookupOK THEN BEGIN vLookupForm.MyGETparameters(vparam1,vParam2,vParam3) Rec. ... := vParam1; Rec. ... := vParam2; Rec. ... := vParam3; Rec.MODIFY(TRUE): END;
0 -
YES, YES!
It works!
First, I was trying on the table - not susscefull, after I tried on form, and it works.
I put this code on OnLookupCLEAR(f);
f.LOOKUPMODE(TRUE);
IF f.RUNMODAL = ACTION::LookupOK THEN
BEGIN
f.GETRECORD(recLookUpTbl);
"Level code":=recLookUpTbl.Code;
"Level Above":=recLookUpTbl."Item Category Code";
CurrForm.SAVERECORD;
END
Key thing was this f.LOOKUPMODE(TRUE); I thought it's quite enough if I have Lookup Properties set OK.
Once again, thanks a lot!!!0 -
My pleasure...
I have the Don Kichot syndrom and mibuso gives me the opportunity to fulfill it. ](*,)0 -
I would like to help also.
But the problem is time.
And as you can see sometimes I cannot solve my problems, not speak of other ones.0 -
Hello all, I have found this thread in a search and hope you can help me.
I find myself in a similar position to merana, I have the form open but have no OK or CANCEL buttons.recLookUpTbl.SETCURRENTKEY("Document Type","Document No.","Line No."); recLookUpTbl.SETFILTER("Document No.","Sales Order"); CLEAR(v_LookupSales); v_LookupSales.SETTABLEVIEW(recLookUpTbl); v_LookupSales.SETRECORD(recLookUpTbl); v_LookupSales.LOOKUPMODE(TRUE); IF v_LookupSales.RUNMODAL = ACTION::LookupOK THEN v_LookupSales.GETRECORD(recLookUpTbl);
My variables are :recLookUpTbl Record Sales Line v_LookupSales Form Sales Order Subform
My filter appears OK as the data in the RUN form is correct.
Trying to learn from info in this thread, I am running from the form not the table.
Can anyone see what I am doing wrong.
Regards
SteveA0 -
Hi,
You are using a form that those buttons have been deleted because it is a subform.
Try using the form 516 as your lookup form or make your own.0 -
Thank you Arhontis, that is working perfectly.
Thanks for both the content and speed of your reply.
Regards,
SteveA0 -
I would just like to ask one more question, really just to aid my own umderstanding. My first port of call is the integrated C/Side Reference Guide.
During a period of trial and error, before the kind reply from Arhontis, I got this to almost work.IF FORM.RUNMODAL(0,recLookUpTbl) = ACTION::LookupOK THEN BEGIN
I was able to get the OK and CANCEL buttons on the Sales Order Sub Form (ID46).
I am just interested why the buttons should be displayed under these circumstances.
Regards,
SteveA0 -
Hi,
First of all, if you have added the two buttons on the form 46 then you will have problems with the Sales Order form which uses that form to show the sales lines. You should use the form 516-Sales Line.
Eash button has properties and one of them is:
InvalidActionAppearance (Normal/Disable/Hide)
which on the OK and Cancel buttons (with the PushAction property is LookupOK and LookupCancel) is hide.
That is to hide the buttons whose action is inappropriate for the current action the form has been opened.
When the form is opened with lookupmode(true) then the two buttons appear.
Does this cover your question?0 -
Arhontis
Thank you once again for your speedy help.
Regards,
SteveA0
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