Form with two DS linked

I need to create a form showing all records from table1 satisfying these conditions:

select * from Table1

inner join table2 where table1.fieldNokey = table2.fieldNokey

and table2.fieldstatus == filterfield ( this field is one input string field added on the top of the form )

.- No relations exist between the two tables

  • No other ds defined in the form just Table1

I tried in this way :

In the init() method of Table1_ds

this.query().addDataSource(tablenum(Table2)).addLink(fieldNum(Table1, fieldNokey ), fieldnum(Table2, fieldNokey ));


criteriaStatus = this.query().dataSourceTable(tableNum(Table2)).addRange(fieldnum(Table2,fieldstatus ));

and in the executequery() of Table1:

criteriaStatus.value(queryValue(ctrlStatus.selection())); where ctrlstatus is the filter field on the form

but it doesn’t work, I receive a crash in the criteriaStatus cause not initialize:

has someone some good links or examples to help me?