I have a field in the job table that is related to a field in another table. When the user drills down and selects a record from the related table the related field is returned to the job table. The problem is that the related table has a primary key with three varables. I want two other fields in the job table to be also be populated based on the selected record. Filtering will not work because of the multple keys. Likewise a "get" statement won't work for the same reason. And, the related table is not initialized or retreived by the drilldown/lookup.
Is there a an easy way to return other varables along with the lookup? I know there must be-- but I can't find anything on this!
0
Comments
re. Get, you need to have ALL primary key fields, to use get.
ie. SalesLine.get(DocType,DocNo,Line);
Kind Regards
Henrik Helgesen,
Navision Solution Developer
<BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Great Minds Discuss Ideas,
Average minds discuss events
Small minds discuss people (With Malicious Intention)
Admiral Hyman Rickover, US Navy<HR></BLOCKQUOTE>
Henrik Helgesen,
President | Helgesen Consulting
about.me | LinkedIN
I understand that I can't use the "get" because of the multiple fileds that comprise the primary key.
Likewise, because there is no single unique field, like a line number, I can not set a filter and use the find function-
I will look again- but are you saying I can specify more than one field to bring back ?
I am not sure I understand your problem. If you want to retrieve more than one field from the form that you made a lookup to, the tablerelation way is probably not your solution. Look at onlookup trigger with GETRECORD Function. See below for more details.
If I am correct you want to lookup from a field on (for example) the job card. Then select a record from a list that appears. Once selected Three of those fields need to populate three fields on the job card.
I don't know of an easy/Quick (relative) way to do this. However, If you use the lookup trigger on the field and handle the lookup yourself, you can make it work. I tested this by creating 2 tables. tbl1 and tbl2. and a form (aform)
tbl1 has 5 fields one,two,three,four & Five. Text 30
Primary key one
one = tablerelation tbl2
tbl2 has 5 fields aaa,bbb,ccc,ddd,eee Text 30.
Primary key aaa,bbb,ccc
in the onlookup trigger of field one
theform = GLOBAL of AFORM
RECORD = GLOBAL of tbl2
theform.RUNMODAL;
theform.GETRECORD(record);
one := record.aaa;
two := record.bbb;
three := record.ccc;
Hope this helps
regards
Craig Needham
IF record.GET(aaa,bbb,ccc)THEN; // This will select the latest selected record
theForm.SETRECORD(record) // This will set the view to that record
IF theFORM.RUNMODAL = ACTION::LookupOK THEN BEGIN
theFORM.GETRECORD(record)
one := record.aaa;
two := record.bbb;
three := record.ccc;
END;
// the 'IF theFORM.RUNMODAL = ACTION::LookUpOK THEN BEGIN' makes sure that when a user hits escape or presses the cancel button, no update will happen.
Dennis
[This message has been edited by Dennis (edited 01-02-2000).]
Qwinsoft BV
The Netherlands
The code you are looking for is similar to the Sales Line table, Appl.-to Item Entry field, OnLookup trigger. It calls a function that lets the user select an Item Ledger Entry, and fills the Location Code, Lot No., Serial No., etc. from the chosen record.
-jp
1. set a local variable in the function (local seems cleaner than a global but global will work.
2. clear your variable
3. set the appropriate key if needed
4. set ranges and filters if needed to narrow the choices that will appear in the lookup form
5. use the if statement to see if the form.runmodal Action returns a lookupOK (i.e. true)
6. Salesline2 is now the specific record you picked in the lookup form
7. You can now assign as many fields as you like from the returned record.
8. Some rules If a lookup is written in a form's control's lookup trigger that overrides the table lookup(code or property). If a lookup is written in a table's field's trigger that overrides the table property lookup.
9. one gotcha --- If there is code in the table's field's trigger Even if it is remmed out or only a comment your property lookup will not work. This one took a long time in a bug hunt.
Code from BlanketOrderLookup
2. SalesLine2.RESET;
3. SalesLine2.SETCURRENTKEY("Document Type",Type,"No.");
4. SalesLine2.SETRANGE("Document Type","Document Type"::"Blanket Order");
4. SalesLine2.SETRANGE(Type,Type);
4. SalesLine2.SETRANGE("No.","No.");
4. SalesLine2.SETRANGE("Bill-to Customer No.","Bill-to Customer No.");
4. SalesLine2.SETRANGE("Sell-to Customer No.","Sell-to Customer No.");
5. IF FORM.RUNMODAL(FORM::"Sales Lines",SalesLine2) = ACTION::LookupOK THEN BEGIN
6,7. SalesLine2.TESTFIELD("Document Type","Document Type"::"Blanket Order");
7. "Blanket Order No." := SalesLine2."Document No.";
7. VALIDATE("Blanket Order Line No.",SalesLine2."Line No.");
END;
sorry i was long winded but I wanted to be clear as possible.
Steve Post
Aston IT Indiana
Indianapolis IN USA