I've modified the InventTable form so the users can filter the items depending on their "Stopped" status on the default order settings setup form. They get a list of the "buyable" items, "sellable" items, all items or blocked items for sale or purchase depending of the values of two checkboxes.
I've added the InventItemSalesSetup and InventItemPurchSetup datasources in the code and I enable or disable them when the user checks or unchecks a checkbox.
Everything works fine except when one of the datasources is disabled. Then the "Advanced filter/sort" option stops working. I get the error: "The data source is not enabled".
The error comes from the method "saveCueEnabled" of the SysQueryForm form. When it calls:
if (!CueRun::canSaveQueryAsCue(this.args().caller()))
return false;
Which calls:
static boolean canSaveQueryAsCue(QueryRun qr)
{
int numOfDataSources, i;
QueryBuildDataSource ds;
Query q;
Common cursor;
;
if (!qr)
return false;
q = qr.query();
if (!q)
return false;
numOfDataSources = q.dataSourceCount();
for(i = 1; i <= numOfDataSources; i++)
{
ds = q.dataSourceNo(i);
if(ds.dynalinkCount() > 0)
return false;
// Check if it is temp
cursor = qr.getNo(i);
if (cursor.dataSource() && cursor.isTmp())
return false;
}
return true;
}
When it gets the number of the datasources in the query, the "dataSourceCount" method also returns the count with the disabled data sources, and when it gets the QueryBuildDataSource of the disabled data sources in the loop you get an empty DS and it crashes when it checks if it's a temporary table.
I've solved the problem adding an extra if on the "saveCueEnabled" code but I wonder if there's a way to enable/disable the data sources without getting this error.
I hope I've explained myself well, thank you!
The only solution I can come up with requires you to modify canSaveQueryAsQue().
This update to the for loop is simple and should solve your issue.
for(i = 1; i <= numOfDataSources; i++)
{
ds = q.dataSourceNo(i);
if(ds && ds.dynalinkCount() > 0)
return false;
// Check if it is temp
cursor = qr.getNo(i);
if (cursor.dataSource() && cursor.isTmp())
return false;
}
I have not tested this code, but I have used similar code in other situations. Hope that helps!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With