Catch data from lookup

hi all! I wold like to choose line from lookup and save lookup fields to another cells. Now i can save only one field (this where parm in addlookupfield is true) Question - how to catch data from lookup??

You need to call the lookup programatically, then add a method in the caller form to populate the needed fields using as paramter the table in the lookup. Then in the lookup screen, on the close method, you will call element.args().caller().() to pass these parms. Regards, Ciprian

I don’t understend where place this method and how it build. Now i overwrite Lookup method on the string edit in grid (i have my own lookup with specific fields) Could you show me a little example??

What Ciprian means, I guess, is that you have to create your own lookup form, not use the standart lookup . So instead of doing what you are right now: tableLookup.AddLookupField(fieldNum(table, field1), true); tableLookup.AddLookupField(fieldNum(table, field2)); well, you know what I’m talking about. You would have to call your own lookup form, and in that form overload the close() method and fill the data you need in the caller form. Will try to give you the exact code in a couple of hours if you still need it.

Ok. So here goes the code: (this is an example) You have 2 forms: Form1 Form2 On Form1 you have 2 controls - StringEdit, StringEdit1 (AutoDeclaration property set to yes) On Form2 you have a DataSource, say, InventTable. And a Grid, with 2 fields - ItemId, ItemName. In the lookup method of Form1 you write the following: public void lookup() { // super(); Args args; Object formRun; ; args = new Args(); args.caller(element);; formRun = classFactory.formRunClass(args); formRun.init(); this.performFormLookup(formRun); } This code shows the Form2 as a lookup - well, you will have to set the properties of Form2 so that it looks as a lookup, but that’s easy- just check any other lookup form in the AOT. Then, overload method closeSelect() on form2. There, you write the following: public void closeSelect(str _p1) { this.args().caller().Method1([InventTable.itemName]); super(InventTable.ItemId); } This will call the Method1 - a method on Form1 we will add later and will return ItemId into the field where the lookup was called from. Ok, next is Method1 on form1: void Method1(container values) { value = conPeek(values,1); } Value has to be declared in the classDeclaration of Form1. And last, you have to set the value into StringEdit1 For this, you overload the modified method on your lookup field StringEdit. public boolean modified() { boolean ret; ret = super(); StringEdit1.text(value); Return ret; } That’s it. You have your 2 values instead of 1. If you have further questions, Will try to help. :slight_smile:

Is nice! thx And i use your example in futhure certain. But (if think is ma own fault, i don’t clear wrote about what i need) i look for little another solution. Let’s see - i have grid with 3 fields. F1, F2, and F3. I wrote my own lookup method - and now in lookup i have 3 fields L1,L2,L3 Next step - on F1 i use lookup method to choice value and fill this cell by lookup field L1. And i need to fill fields F2, F3 by value from L2, L3. Now i’m sitting and think how to use your example in ma case. If you have any advice for me i would be very happy. [:)]

No, the example I gave should do your job. Ok, let’s take it one step at a time. Your grid is bound to a DataSource. So the fields in the grid - f1-f3 are fields from a table. Right? So, the only thing you have to change in the code I gave is method modified on F1. public boolean modified() { boolean ret; ret = super(); // StringEdit1.text(value); //here you insert values into your fields in the table YourTableName.F2 = value; YourTableName.F3 = value2; // and you need to refresh your datasource to show the values changed YourTableName_ds.refresh(); Return ret; } Well, as you might have noticed, you need 1 more variable - value2 (add it in classDeclaration as variable value) And what I want to ask you is - if L1 a key field in table the lookup is based on? Because in this case you can simple use display methods to show the values of L2 and L3 in F2, F3. It would save a lot of code. :slight_smile: (what i mean is this: for example you want to select ItemId in F1, and fill F2 and F3 with ItemName and ItemGroup - and in the lookup these are the fields that are L1, L2 and L3.)

Nice thx, i did it! And the last question if i want to see in my lookup only the lines with the same id like the line witch from i open it - i should use args.record(table::find(…)) or build query or something another??

Yes. Something like that. In the lookup method you add the line with args.record Only instead of Table::find(), better use YourDatatSourceName_ds.cursor() or simply YourDatatSourceName; I think both are correct. And then, in the lookup form - in the init method of the datasource you add a range on this field, and set its value from your args.record() And if no value is present, than you have to set the value for this range like this: range.value(SysQuery::ValueUnlimited()); That will return all rows then