Hello everyone,
We have a form called BOMPartOf that shows all the BOM's an item is a part and then on the bottom part of the form, it shows the BOM Version
I have a request from a user to duplicate this form but only show BOM's that item is a part of that have active BOM Versions
So to start, I duplicated the form
The form has BOM and BOMVersion as datasources so the first thing I tried was to add a range to BOMVersion in code like this
[DataSource]
class BOMVersion
{
void init()
{
Query query;
QueryBuildDataSource qbds;
super();
query = new Query();
qbds = query.addDataSource(tablenum(BOMVersion));
qbds.addDynalink(fieldnum(BOMVersion,bomId),bom,fieldnum(BOM,bomId));
criteriaVersionFromDate = qbds.addRange(fieldnum(BOMVersion,FromDate));
criteriaVersionToDate1 = qbds.addRange(fieldnum(BOMVersion,ToDate));
criteriaVersionToDate2 = qbds.addRange(fieldnum(BOMVersion,ToDate));
criteriaVersionActive = qbds.addRange(fieldNum(BOMVersion, Active));
criteriaVersionActive.value(queryValue(NoYes::Yes));
this.query(query);
}
The problem is, this didn't filter the top part of the form with the BOM's, only the bottom part of the form showing BOM versions. It would now only show the version, if it was active.
Then I tried to add a datasource and range to the BOM table in the init like this
void init()
{
Query query;
QueryBuildDataSource qbds;
super();
query = new Query();
qbds = query.addDataSource(tablenum(BOM));
criteriaBOMItemId = qbds.addRange(fieldnum(BOM,ItemId));
criteriaBOMFromDate = qbds.addRange(fieldnum(BOM,FromDate));
criteriaBOMToDate1 = qbds.addRange(fieldnum(BOM,ToDate));
criteriaBOMToDate2 = qbds.addRange(fieldnum(BOM,ToDate));
bom_ds.query(query);
pmfFormCtrl_BOMPartOf.dataSourceInitPost(bom);
}
This didn't do anything, so lastly I added another BOMVersion to the datasources and renamed it BOMVersionActive
I joined it to BOM and then I tried to filter it in the code like this
[DataSource]
class BomVersionActive
{
///
///
///
public void init()
{
Query query;
QueryBuildDataSource qbds;
super();
query = new Query();
qbds = query.addDataSource(tablenum(BOMVersion));
qbds.addlink(fieldnum(BOMVersion,bomId),fieldnum(BOM,bomId));
criteriaVersionActive = qbds.addRange(fieldNum(BOMVersion, Active));
criteriaVersionActive.value(queryValue(NoYes::Yes));
this.query(query);
}
}
But this gives me an error that says The data sources is not embedded within a parent data source.
Basically I'm just trying to duplicate this.....
SELECT *
FROM BOM
JOIN BOMVERSION ON BOMVERSION.BOMID = BOM.BOMID
WHERE BOMVERSION.ACTIVE = 1
Anyone have an idea what I could be doing wrong?