Searching function problem

Hi!:wink:
I am trying to use the search function of a grid application,
but then I found out that I cannot search those field that does not exist in the original table.
For example, I created a field Dpt.Name with a grid lookup in order to retrieve a field from the other table:

Grid of Table A:
Name | Dpt.Code | Dpt.Name

Grid of Table B:

Dpt.Code | Dpt.Name

But then when I use the search function on that grid of Table A, I found out that I cannot search those records by typing Dpt.Name,
also if I try to perform a dynamic search on Dpt.Name, a error message will popup:

Is there any way to perform searching on fields that doesn’t belong in the orignal table?

Capture.PNG

Yes, but not what you like … You must create a new (hidden) field for the full Dpt.Name and fill this field at event onRecord.

I did that too,by using something like this:
$id={id};
$sql=“SELECT contact_name
FROM supplier_contact
WHERE supplier=”.$id;
sc_lookup(ds,$sql);
{contact}={ds[0][0]};

but that when type in a contact_name exist in one of those fields to search, no result is shown in the quick search,
and there is still an error message pop up if I use dynamic search.

Have you included the contact field in the field list for quicksearch and select a search criteria (scroll down …)?

Yes, but the searching still won’t work :confused:

Ah, is see … report this as bug: a manuell included field(name) is not included in the sql search condition via quick search.

Think it through, it can’t work because you cannot search for something that doesn’t exist in the record set.

To make it work you have to either create a view and base the grid on it or join the tables in the SQL statement of grid A.

SELECT name, deptcode, deptname FROM table_a a LEFT OUTER JOIN table_b b ON a.deptcode = b.deptcode

That should do it.

jsb

I had the same issue with one of our projects and I had to create a view in MySQL then I could search/sort how I wanted.

Dave

Hi Brian,
I agree with JSB. Move that within the SQL using the right Join type.

Yes, you are right … Thanks!