Page 1 of 1

Lookup Control / return concatenated fields

Posted: Tue Feb 06, 2018 1:56 am
by toms
Hi,

I'm trying to return two concatenated fields from a Browse Form to the description field of a lookup control.

My first attempt was to concatenate the fields directly in the query. Result: The Browse Form stays empty.
concat_sql.PNG
The 2nd attempt: By concatenating the fields in the Display row I can see the field appear on the Browse Form.
contact_display.PNG
Now my question is how I can pass that "fullname" field to the lookup control? Adding an alias for the concatenated fields (like CONCAT(gd_vorname, ' ', gd_nachname) as full_name) doesn't work.
lookup_description.PNG

Re: Lookup Control / return concatenated fields

Posted: Tue Feb 06, 2018 4:57 am
by admin
toms,

Try this...
lookup_description.PNG
Steven

Re: Lookup Control / return concatenated fields

Posted: Tue Feb 06, 2018 6:41 am
by toms
Steven,

Thank you, it works like this. Why didn't I think of that...?

Re: Lookup Control / return concatenated fields

Posted: Tue Feb 06, 2018 7:24 am
by admin
toms,

It will only work with fields from the table connected to the Lookup.

Not fields from any SQL joins.

If you want to do something more complicated, like how much a customer owes.

You could do that with PHP in After Browse.
after_browse.PNG
You could do something like this...

Code: Select all

$lur    = nuLookupRecord();
$i      = $lur->ID;
$s      = "
        SELECT SUM(inv_total) 
        WHERE inv_paid = '0'
        AND inv_customer_id = '$i'
        ";
    
$t      = nuRunQuery($s);
$r      = db_fetch_row($t);

nuSetFormValue('rep_customer_iddescription', "Currently owing : " . $r[0]);

Steven

Re: Lookup Control / return concatenated fields

Posted: Tue Feb 06, 2018 7:31 am
by toms
Steven,

Thanks for the additional example. I've just nuLookupRecord() so far but not in combination with
nuRunQuery() etc.

Re: Lookup Control / return concatenated fields

Posted: Tue Feb 06, 2018 7:38 am
by admin
.