Hello. I'm Lee and I've been using Axapta at work for about 2 months now. I like it very much but am having a really hard time getting some good documentation and tutorials. Are there any popular ones out there ?
Currently I'm working on an automated daily report that runs via the batch. One of the criteria is that the date field of the table I am reporting on is the previous day from whenever the report is run. I.e. today()-1.
Obviously I can't enter this function as a criteria in the date range when the report is run or auto-run -- I can only enter a specific date or date range. So what I need is to modify this range via X++ in one of the report's functions before the report is run.
My first attempt was to override the report's init() function as follows:
public void init()
{
QueryBuildDataSource qbds;
QueryBuildRange qbr;
;
super();
//Change the date range to only list yesterday's calls.
qbds = Query.DataSourceTable(TableNum(MSM_SvcCallTable));
qbr = qbds.AddRange(FieldNum(MSM_SvcCallTable, LocalCloseDateStamp ) ) ;
qbr.value( date2str( today()-1,123,2,2,2,2,2 ) );
}
This fills in the date field OK but has a problem: When the day ticks over (simulated by changing my system clock) and the report is re-run, it still uses the previous value. Only by hitting the "reset" button for the criteria can I make it update the date again.
Is there a way to programmatically do this via X++?
Also, when I run the same report through a menu or menu item (i.e. instead of straight from the AOT), the date range does not show up at all.
Now I admit I'm a complete Axapta noob and am probably miles away from the correct way of doing this, but could anyone please provide me with a tidbit of advice to help me out ?
Thanks in advance
Lee.
0
Comments
Welcome to this forum
As far as learning Axapta, please check my other posts on this topic.
For resetting the previous range, you might want to call clearRanges method like this -
qbds.clearRanges();
After this, try adding the range.
Hope this helps,
Long way to go before I sleep..
I would think that this query is not connected to the report at all.
To do this you have to write a line like this:
And also, if Harish's advice to clear the ranges won't help, try using the YourQuery.reset() function.
Good luck in learning Axapta.
My blog - http://kashperuk.blogspot.com
MorphX IT in Russian - http://www.lulu.com/content/723888
Inside Dynamics AX 4.0 in Russian - http://www.ozon.ru/context/detail/id/3714582
This is something new that I learned today. Thanks
Sorry couldn't help
My blog - http://kashperuk.blogspot.com
MorphX IT in Russian - http://www.lulu.com/content/723888
Inside Dynamics AX 4.0 in Russian - http://www.ozon.ru/context/detail/id/3714582