Form/Prodtable, I need to filter some records based on complex criteria not manageable by query range
In the init method of the form I’ve just added the following instr which create the ProdTableTmp (tempDB having just one field ProdId and a relation to ProdTable)
if (element.args().dataset() == tableNum(BOMVersion))
{
BOMVersion = element.args().record();
this.createProdTableTmp(bomVersion);
}
debugging I can see the tmp records created successfully
and in the init() of the ProdTable Datasource the following;
super();
if (element.args().dataset() == tableNum(BOMVersion))
You asked the query to create a ProdTableTmp buffer, but you didn’t provide any data, therefore the query doesn’t return anything. That’s expected.
Set the temporary buffer to the QueryRun object through setRecord().
Alternatively, add ProdTableTmp as a datasource and either link it with the data through linkPhysicalTableInstance(), or disable the datasource (if the record argument isn’t BOMVersion).
Well, I tried it and although the setRecord() works well with normal queries, there is some problem with forms. Rather than wasting too much time with investigating, I suggest you use the other approach I described.
Alternatively, you could wait until AX initalized the QueryRun object (e.g. in run() below super()), get a reference to the table buffer (e.g. SomeTable_ds.queryRun(get(tableNum(…)) and insert data there (with insert() as usual). But the other approach (using a form datasource and disabling the QueryBuildDataSource if it isn’t needed) makes better sense to me.