Notifications
Announcements
I am trying to create a report where the starting date is already coded and the ending date the user puts in and based on the ending date I get the report I want. How can I code that?
*This post is locked for comments
Hi mjcjyk,
Not what you're asking for, but I have to start with: "hard-coding a date is a bad idea... why not prompt the user to enter it, or have a field on a setup table that can be populated with the starting date (and changed as/when needed)".
Ok, now that that's off my chest, let's answer your question. Let's say you want your starting date to be locked in at 12/31/15. You'll need to set two variables in your report object of type Date, one for the Starting Date and one for the Ending Date. For the Starting Date (let's say you called the variable StartingDate), set it to your desired date with:
StartingDate:=123115D;
The Ending Date will likely be populated by the user in the Report Request Page, so make sure you have a field there feeding your EndingDate variable.
It's been a while since I've written a single line of code in C/AL, but this should do the trick.
Good luck. If you need more help with C/AL or Report writing, there are some nice e-Learning resources available through Microsoft CustomerSource (or PartnerSource, if you are a partner).
I hope this helps. If my response has answered your question, please verify by clicking Yes next to "Did this answer your question?"
Hi AJ,
How would I code the End Date in the Report Request Page?
I have it as:
IF EndDate <> '' THEN
SETFILTER("Posting Date", '%1', EndDate)
Would it be something like what I typed?
Thank you,
You'll need to make one change: When working with the Date data type, a blank value would be 0D instead of ''
The Setfilter part should be good (but missing an ; if there's no ELSE following it), but like I said, a little rusty here.
SETRANGE("Posting Date",0D, EndDate);
This will show data till end date.
If you startDate hardcoded in program then you can write something like
If EndDate <>0D THEN
SETRANGE("Posting date",StartDate,EndDate);
Resolved my issue. Thank you.
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.
HoangNam 7