Passing queries between classes and forms

I created a class, ProcessInventData, that extends RunBaseBatch and created a custom form for the dialog (similar to \Forms\tutorial_RunbaseForm). When running the RunBaseBatch class, the dialog (I’ll refer to as Form A) comes up which the user can provide parameters and also customize the query via the Select button. I also have another button that launches yet another form in which I pass the current query.

The new form (I’ll refer to as Form B) has a datasource that is the same type that is contained in the query that is passed. The grid displays the data filtered based on what the original query was setup as in the original dialog (Form A). This is done via the following command in the Init() method of the data source:

this.query(ProcessInventData.queryRun().query());

All is well so far. However, the issue starts to occur when I add another Data Source to Form B, such as Inventory Dimensions. Once I set that datasource to inner join on the primary data source, I get the following error:

The data source name InventDimTableA is already used. Each data source name must be unique in the query.

There is no pre-exisiting Data Source with the same name in Form A, Form B or the original RunBaseBatch class. Strange indeed.

I have tried to unset the Join type for the InventDim datasource in Form B and do all the query manipulation in the RunBaseBatch class, hoping that the query will be carried over, but it is not, even if I override the Init() method in the InventDim datasource using the same this.query(ProcessInventData.queryRun().query()); call.

Eventually I would like to add additional tables to the query in my RunBaseBatch class’s initQuery();

Any answers and insight are greatly appreciated!

When you do this.query(ProcessInventData.queryRun().query());, do this after (or if this doesn’t work, some variation of it):

InventDim = this.queryRun().get(tablenum(InventDim));
And look and see what it thinks is in InventDim.  That might give you a start?

No dice buddy. However, you did provide me with something to try, that is, to pass a query to a form and explicitly replacing the query in the data sources. My only question with that is what is the appropriate way to do this, especially with a complex query that has multiple datasources.

Strangely enough, setting the property “Auto Query” to “No” on the Data Source solved the issue as far as the error coming up. Seesh, hours spent on such a small property change!

Let’s see how my ultimate goal works out, which is to have multiple data sources in my RunBaseBatch class in a complex query that gets passed to the form.

I believe you can do inventDim.data(yourReplacementTable); Then a refresh.