Problem with lookup table and autofill, with master / detail

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
rrezende
User
Posts: 15

Problem with lookup table and autofill, with master / detail

Post 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?


arbei
User
Posts: 9376

Post by arbei »

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


mobhar
User
Posts: 11712

Post by mobhar »

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


rrezende
User
Posts: 15

Post 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


Post Reply