Lookup field ID

The recommended method of customizing your AppGini-generated application is through hooks. But sometimes you might need to add functionality not accessible through hooks. You can discuss this here.
Post Reply
mdspine
Veteran Member
Posts: 34
Joined: 2020-06-06 12:38

Lookup field ID

Post by mdspine » 2020-09-30 00:03

I have a Invoice Table (with 3 fields InvoiceID, InvoiceDate, CustomerLookup) .
The CustomerLookup is a lookup field of Customer Table which has 2 fields(CustomerID, CustomerName)

I need to get the CustomerID of the customer from a given InvoiceID

$Invoice_from = get_sql_from('Invoice');
$Invoice_id = intval($_REQUEST['InvoiceID']);
$Invoice_fields = get_sql_fields('Invoice');
//Need the syntax to get CustomerID for a given InvoiceID

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1709
Joined: 2018-04-01 10:12

Re: Lookup field ID

Post by pbottcher » 2020-09-30 06:10

Hi,

acutally, if you need the CustomerID, this is the data stored in the CustomerLookup field of the Invoice table.

SELECT CustomerLookup from Invoice where InvoiceID = ID_YOU_SEARCH_FOR
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

mdspine
Veteran Member
Posts: 34
Joined: 2020-06-06 12:38

Re: Lookup field ID

Post by mdspine » 2020-09-30 12:03

Appreciate it will try

mdspine
Veteran Member
Posts: 34
Joined: 2020-06-06 12:38

Re: Lookup field ID

Post by mdspine » 2020-09-30 23:38

Hi
I used

Code: Select all

$IDofPatient=SELECT PatLU from Billing where BillingID = 2;	
echo $IDofPatient;
I get this error
Parse error: syntax error, unexpected 'CustomerLookup' (T_STRING) in /mydomain/TEST.php on line...
Please advise

mdspine
Veteran Member
Posts: 34
Joined: 2020-06-06 12:38

Re: Lookup field ID

Post by mdspine » 2020-10-01 01:22

Sorry

Code: Select all

$IDofCustomer=SELECT CustomerLookup from Invoice where InvoiceID = 2;	
echo $IDofCustomer;

mdspine
Veteran Member
Posts: 34
Joined: 2020-06-06 12:38

Re: Lookup field ID

Post by mdspine » 2020-10-01 21:03

I was able to figure that out
it should be

Code: Select all

$IDofCustomer= sqlValue("select CustomerLookup from {$Invoice_from} and InvoiceID= {$Invoice_id}", $eo);
The key as sqlValue instead of sql

Thanks

Post Reply