Question Status

Verified
RickC1971 asked a question on 12 Aug 2014 6:16 AM

Hi,

Hopefully someone can help me? I have a report that I've written that produces results based on todays date. The date parameter is configured via a UIBuilder that populates the date parameter with todays date and works great when run manually by a user. What I've been asked to do is to automate the delivery of the report via email on a daily basis. I set the report to run as a batch thinking it would just work, but for some reason the date parameter is always set to the date that the batch job was created, not todays date. Has anyone got any ideas how to get around this?


Thanks in advance.

Reply
Verified Answer
RickC1971 responded on 19 Aug 2014 2:28 AM

I couldn't figure out how to get AX to use the default dates set in the UI when running the report in a batch. So I used a workaround. I created a Boolean parameter call "run in batch" and looked for this switch in the Data Provider. If the parameter was set to true, I calculated the start and end date for the report in code. If the parameter was false, I used the start and end date provided in the UI. It's a bit "ham fisted" but it works.

Reply
Suggested Answer
André Arnaud de Calavon responded on 12 Aug 2014 6:34 AM

Hi Rick

Take a look at the Inventory closing job. This is using Period codes to determine the date.

kind regards,

André Arnaud de Calavon  |  Microsoft Dynamics AX Solution architect  |  My blog  |  My company

This post is my own opinion and does not necessarily reflect the opinion or view of my company, Microsoft, both its employees, or other MVPs.

Reply
Suggested Answer
André Arnaud de Calavon responded on 12 Aug 2014 6:34 AM

Hi Rick

Take a look at the Inventory closing job. This is using Period codes to determine the date.

kind regards,

André Arnaud de Calavon  |  Microsoft Dynamics AX Solution architect  |  My blog  |  My company

This post is my own opinion and does not necessarily reflect the opinion or view of my company, Microsoft, both its employees, or other MVPs.

Reply
RickC1971 responded on 13 Aug 2014 3:33 AM

Hi Andre,

Thanks for your reply. I'm still learning AX and I don't quite understand what you mean when you say to look at the Inventory Closing job. Please can you tell me where I can find this job?

Thanks.

Reply
André Arnaud de Calavon responded on 13 Aug 2014 4:02 AM

Hi Rick,

Sure; no problem. The periodic option in menu Inventory management, Periodic is called "Closing and adjustment". On this form you can click the button 'Recalculation'. Then you will see the dialog with a period code field which determines the date on the dialog, but also in runtime.

The class used is called: InventCostClosingRecalc.

kind regards,

André Arnaud de Calavon  |  Microsoft Dynamics AX Solution architect  |  My blog  |  My company

This post is my own opinion and does not necessarily reflect the opinion or view of my company, Microsoft, both its employees, or other MVPs.

Reply
RickC1971 responded on 13 Aug 2014 4:49 AM

Thanks Andre,

I've had a look at your suggestion, but I think I may not have explained myself properly.

My report works fine when run manually, the user opens the report, the dates are set in the parameters UI automatically and all the user needs to do is click OK to run the report.

I was hoping that when I set up a batch to send this report via email, the batch job would honour the date parameters that are set automatically at runtime just as if it had been run manually, but it looks as though the parameters are being set via some other mechanism when run via a batch.

Strangely though, if I look at the batches task and click the parameters button, I see the parameters dialog box with the correct dates set, but for some reason, when the batch runs, the run date is the date that the batch was created.

Rick.

Reply
Verified Answer
RickC1971 responded on 19 Aug 2014 2:28 AM

I couldn't figure out how to get AX to use the default dates set in the UI when running the report in a batch. So I used a workaround. I created a Boolean parameter call "run in batch" and looked for this switch in the Data Provider. If the parameter was set to true, I calculated the start and end date for the report in code. If the parameter was false, I used the start and end date provided in the UI. It's a bit "ham fisted" but it works.

Reply