Page 1 of 1

Problem with lookup table and autofill, with master / detail

Posted: Thu Oct 12, 2017 4:49 am
by rrezende

I have a problem with lookup table and autofill, with master / detail.
For the same product I have different prices per customer, I have a product price table per customer.
Use lookup table to select the customer on the screen of purchase orders (master)
In the product table use table lookup to select the product, and autofill to fill in the value.

I'm using parent / filter from the master table for the detail, works fine to select the products, but the autofill ignores the filter, which in the case is the client code.

Mysql Log:
Query autofill: SELECT value AS FIELD0, amount_file AS FIELD1 FROM vw_services_properties WHERE (server_code = 47) ORDER BY ASC_services
Query lookup Table: SELECT AS-LinkFld, AS DispFlds, AS Disp2Fld, AS Disp3Fld, AS Disp4Fld FROM vw_proposals WHERE (proposal_type IN (1)) AND ( client_code IN (100115) ) ORDER BY desc_services ASC LIMIT 0, 10

The autofill Query should filter through the proposal_type and customer_code fields.

Where am I going wrong?


Re: Problem with lookup table and autofill, with master / de

Posted: Tue Oct 17, 2017 9:21 am
by arbei

Please also post your table schema, so others can know the relationship between your tables.


Re: Problem with lookup table and autofill, with master / de

Posted: Wed Oct 18, 2017 12:10 pm
by mobhar

Try to run those 2 queries using your database manager, does it work?


Re: Problem with lookup table and autofill, with master / de

Posted: Wed Oct 18, 2017 7:27 pm
by rrezende

Solved with ew_Ajax

I needed to automatically populate an autofill field from a compound keyed table.

The solution was to use in the in addpage-> Client Script the following code.

$(document).ready( function() {
$("[data-field='x_servico']").on('change', function() {
var $row = $(this).fields();
var cliente = $("#x_cliente").val();
var servico = $row.servico["0"].defaultValue;
var result = ew_Ajax("<?php echo ew_Encrypt("SELECT valor FROM vw_servicos_propostas WHERE cod_cliente = '{query_value_1}' AND cod_servico = '{query_value_2}'") ?>",{q1:cliente,q2:servico});
$row["preco_unitario"].val(result.toString().replace(".", ","));
});
});

$("#x_cliente") is a field of the master table
$("[data-field='x_servico']") is a field of the detail table