I have added a Relations table utilizing "TableGroupAll" functionality to link Vendors and Inventory Items, so that we can limit what items can be bought from which vendors. On the table, I have the relations set up as such:
VendGroup:
VendRelation.VendCode == 1 [This is the tablegroupall field]
VendRelation.VendRelation == VendGroup.VendGroup
VendTable:
VendRelation.VendCode == 0 [This is the tablegroupall field]
VendRelation.VendRelation == VendTable.AccountNum
Same thing for the InventItemGroup & InventTables.
I have a set up a form to allow administration, and the form works perfectly. If you select "Group" form "VendCode", then the VendRelation drop-down field shows Vendor Groups. If you choose "Table", it shows individual vendors. So far, so good.
The problem I keep running up against, however, is how to add this information to the VendTable form. I added the VendRelations table as a datasource. I have a separate tab set up, and I want to display only the records relevant to the specific vendor on the grids on that tab. I separated out any set to "All" into their own form (that was ridiculously easy and a stop-gap measure until I can figure out the rest).
I added another datasource and grid so I can display the correct values per Vendor (If the VendorCode is set to Group, show items where the vendor is in the group from the VendRelation field; If the VendorCode is set to Table, show items where the Vendor Account Code is equal to the value in the VendRelation field).
This is a nightmare. I have done the groundwork, I think. I've added this to init() on the datasource. Sorry for the crappy formatting.
qbr1 = sysQuery::findOrCreateRange(
this.query().dataSourceTable(tablenum(VendRelation)),
fieldnum(VendRelation,Disapproved));
//VendCode is the TableGroupAll field
qbr2 = sysQuery::findOrCreateRange(
this.query().dataSourceTable(tablenum(VendRelation)),
fieldnum(VendRelation,VendCode));
//VendRelation would be either the AcctNum/VendGroup, based on if the VendCode was "Table" or "GroupID"
qbr3 = sysQuery::findOrCreateRange(
this.query().dataSourceTable(tablenum(VendRelation)),
fieldnum(VendRelation,VendRelation));
But, no matter what I do in the executequery, I cannot get it to display items where the VendRelation field matches the VendorAcctNum AND items where the VendRelation field matches the VendorGroup. And this is where I go off the rails
If (VendTable.VendGroup == VendRelation.VendRelation)
//If I'm correct, what I need to do here is select the current record's value and compare it - not sure how to do this)
{
qbr2.value(queryValue("Group")); //This is the VendCode
qbr1.value(queryValue(0)); //Approved or not
qbr3.value(VendTable.VendGroup); //again, is this where the problem is?
}
Else
{ If (VendTable.AccountNum == VendRelation.VendRelation)
{
qbr2.value(queryValue("Table")); //This is the VendCode
qbr1.value(queryValue(0)); //Approved or not
qbr3.value(VendTable.AccountNum);
}
}
super();
}
Any ideas? Is this even the way to go about it?