Linking a datasource in form by using query….
The below code is used to filter the customers against whom atleast one Sales order has been raised..
public void init()
querybuilddatasource qbds, qbds1;
qbds = custtable_ds.query().dataSourceTable(tablenum(custtable));
qbds1 = qbds.addDataSource(tablenum(salestable));
qbds1.addLink(fieldnum(custtable, accountnum), fieldnum(salestable, custaccount));