Autofill based on two fields selection

Categories PHP

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');
field3.setValue(result["field3"]);

More info about field events:
PHPRunner
ASPRunner.NET

2 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 !!!

Leave a Reply

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