Autofill based on two fields selection


Autofill is a handy feature that allows quickly fill multiple fields after lookup wizard selection. However, it only works based on a single lookup wizard selection. In this article, we will show a more advanced example of implementing a custom Autofill based on two field selection.

field1 – first lookup wizard
field2 – second lookup wizard
field3 – field to be filled after field2 selection
table1 – lookup table where autofill data is coming from

Create a field event based on ‘editing’ for field2.

ClientBefore code

var field1 = ctrl.getPeer('field1');
var field2 = ctrl.getPeer('field2');
params["field1"] = field1.getValue();
params["field2"] = field2.getValue();

Server event

PHP code

$result["field3"] = DBLookup("SELECT field3 from table1 where field1 = ".$params["field1"]." AND field2 = ".$params["field2"]);

C# code

dynamic result = XVar.Array();
result.InitAndSetArrayItem(tDAL.DBLookup(MVCFunctions.Concat("SELECT field3 from table1 where field1 = ", params["field1"], " AND field2 = ", params["field2"])), "field3");

ClientAfter code

var field3 = ctrl.getPeer('field3');

More info about field events:

4 thoughts on “Autofill based on two fields selection

  1. Nice!!!!!! As always !!!
    Is there a possibility to have a datailed manual of all new API – functions of objects ?
    ctrl.getpeer() IS ABSOLUTELY NEW !!!

  2. Buenas tardes, felicitaciones por vuestra página.-
    Por favor necesito actualizar el stock que traigo en la tabla detalle( codigo, descripcion, precio unitario, cantidad, importe , STOCK) con lookup wizard , ese valor que ya lo tengo por éste método, llevarlo a la tabla maestro de artículos….STOCK (para actualizar el stock).-
    Aguardo respuesta.-
    (Hoy con fecha 20/08/2021 me registré en vuestra página)

Leave a Reply

Your email address will not be published. Required fields are marked *