validate()

can anyone help me with an advice or an example? I created a class that extends RunBaseReport I overloaded the validate() method, to check the values of some of the controls on the dialog. What I need to do is check the value of a QueryRange (if it is empty or not) Can it be done? I was trying to use this code, but it shows an error when I am trying to select the value in the SysQueryForm, because the range value is still empty at this moment. if (!this.queryRun().query().dataSourceTable(tableNum(LedgerLiquidity)).rangeField(fieldNum(LedgerLiquidity, AccountNum)).value()) { error("The Ledger account number is empty"); ret = false; } Maybe in some other method? Thanks

What about using: this.queryRun().query().dataSourceTable(tableNum(LedgerLiquidity)).rangeField(fieldNum(LedgerLiquidity, AccountNum)).value() == " "

no. this won’t do. I need to see if the value is empty or filled in. If it is " ", it means it is not empty. But the system doesn’t know it yet, and the real value is still “” when I need to get " " at this moment

Have you tried placing this check on any of the methods on the report?

No, that wouldn’t work either, because the validation is needed on the query form - before the report is initialized. The solution was found and it is a very simple one. There is a parameter in method validate(Object calledFrom) and so you can check it first: if (calledFrom.name() == formStr(SysQueryForm)) return ret; simple!! Thanks for your responses. :slight_smile:

Good!! Is it possible to populate a temp table based on a range for example of accounts.? How can a select from another table based on a range a user enters (entered from the SysQuery form) and populate a temp table?

what exactly are you trying to do? I didn’t understand from your question. A user specified ranges for a query in SysQueryForm, and you want to insert records that are valid for these ranges, into a temptable. If yes, than you just have to create a QueryRun for this query and insert records into TempTable for each queryRun.next() (tableBuf = queryRun.get(tableNum(TableName)))

Does this (QueryRun) get called as soon as the user presses Ok on the dialog box to run the report? Let me explain further: Lets say I create a class that extends RunBaseReport that will run a report based on the query range on LedgerTable. The user will select the accounts. Depending on the range of accounts the user selects then this range is placed in a temp table with the Accounts Name and other info and then the report will display the information based on the temporary table. Would the QueryRun object be placed on the class and called automatically once the user clicks ok to generate the report?

well, in the overloaded initQuery() method of your class you can create a query that you want. And when you press OK, it will be passed on into the report, that you specified in the lastValueElementName method. and in the init method of the report you can fill the temp table (better write a method on the table for this), and put this table as the datasource of your report.

so if the user enters a range of let’s say 1010…1030. How would I jus get the information for that range between 1010 to 1030 using X++ in the method of the temp table?

this range 1010…1030 is stored in the query object (the one that the user modifies) so in the init method of the report you pass this query into the table-method as a parameter and there you do the following: void fillTempTable(Query _q) { QueryRun qr = new QueryRun(_q); YourTable tableBuffer; yourTempTable tempTable; ; while qr.next() { tableBuffer = qr.get(tableNum(YourTable)); //here you set values of the temp table tempTable.field1 = tableBuffer.Field3; //.... tempTable.insert(); } }

I can’t seem to get it to work. Step 1: Build the query in the initQuery? Step 2: Build fillTempTable method? Step 3: Pass query from init method of report.? How would I pass this query into the table-method as a parameter from the init method of the report? What would this look like?

like this: YourTempTableName::fillTable(element.args().caller().queryRun().query());