Notifications
Announcements
No record found.
*This post is locked for comments
The value is (very likely) packed and saved to the database. The batch process load it and use it for records filtering or something.
If the report is never used without a value in runDate, you can fill the value with current date (after unpacking, for example in the run() method) if it is empty. If empty runDate is acceptable, you need an additional variable to distinguish "all dates" and "current date" meaning.
Another approach could be to use query and fill "(currentSessionDate())" as a range value, but it is not applicable in all cases.
Hi Martin,
Thank you for the reply. I have already tried to add the range value in the run method but still have no success:
public void run(){ ; this.query().dataSourceTable(tableNum(CustInvoiceJour)).addRange(FieldNum(CustInvoiceJour, InvoiceDate)); this.query().dataSourceTable(tableNum(CustInvoiceJour)).findRange(fieldNum(CustInvoiceJour, InvoiceDate)).value(strFmt("%1", today())); super();}
Your advice to use currentSessionDate()... Can you give me an example? It is worth trying. Thank you very much.
I don't understand if your application logic uses a member variable (runDate in your first example) or a query. That is big difference.
About currentSessionDate(): AX2009 contains the class named SysQueryRangeUtil. Methods defined in that class can be used directly in the query ranges (when you are defining your batch process). Unlike direct query range values, methods from SysQueryRangeUtil must be enclosed in additional parentheses. See an example:
Martin,
My report is based off of query built using AOT. The 'dialog' method is overriden to add a variable runDate to specify which date to apply to the query (my query range). In the run() method, it was originally coded to pass in the range:
this.query().dataSourceTable(tableNum(CustInvoiceJour)).findRange(fieldNum(CustInvoiceJour, InvoiceDate)).value(strFmt("%1", runDate));
But I can't seem to get it to only pass in todays date and not the saved (packed) date when you first schedule the batch. Does this clarify?
Thanks again for all the help.
OK, so you can easily set it as a field range in RunBase dialog and you don't need to play with class variables. :-)
I didn't try it but I'm not sure if ("%1", runDate) creates a correct range value. The standard implentation (in SysQuery::value()) is different.
Check if the resulting query is really what you want (call this.query().dataSourceNo(1).toString() to get text a represenation of the query).
The issue could be also in using of today() in the impersonated batch job.
Or there is some additional date-based logic somethere in that class…
I used your output statement info(strfmt("%1", this.query().dataSourceNo(1).toString())); and I get back (in short):
SELECT * FROM ...
JOIN * FROM CustInvoiceJour WHERE CustTable.AccountNum = CustInvoiceJour.InvoiceAccount AND ((InvoiceDate = {ts '2010-06-03 00:00:00.000'})) JOIN * FROM CustInvoiceTrans WHERE CustInvoiceJour.InvoiceDate = CustInvoiceTrans.InvoiceDate AND CustInvoiceJour.InvoiceId = CustInvoiceTrans.InvoiceId
Is the InvoiceDate = {ts '2010-06-03 00:00:00.000'} part causing errors?
It depends on what you expect. If the entire query is correct ({ts '2010-06-03 00:00:00.000'} is absolutely valid range value), but behavior of the application is not… the problem probably isn't in the query.
I agree. There is nothing wrong with the query. It is an issue of what is being saved from the last reportRun. This one is frustrating. I'll let you know if we come up with some sort of solution and hopefully find the root of this problem.
Thanks for the help.
Regards.
initialize the date value in the dialog method, right after the dialog =super(_dialog); statement
public Object dialog(Object _dialog)
{;
dialog =super(_dialog); statement
toDate = systemDateGet() -7; // or use date functions from Global class ex: start of month, end of month etc
dialogToDate = dialog.addFieldValue(typeid(PeriodEnd), toDate, "@SYS14656");
return dialog;
}
Under review
Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.
As AI tools become more common, we’re introducing a Responsible AI Use…
We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
Priya_K 4
Martin Dráb 4 Most Valuable Professional
Ali Zaidi 2