Hi
I have 2 dates Start From & End Date . I want if they are not blank , it should be checked that End Date >= Start Date.
Secondly if Dates are not blank then SetRange should be done on Posting Date.
Thanks
*This post is locked for comments
Hi
I have 2 dates Start From & End Date . I want if they are not blank , it should be checked that End Date >= Start Date.
Secondly if Dates are not blank then SetRange should be done on Posting Date.
Thanks
*This post is locked for comments
You can write something like:
IF (StartDate <> 0D) and (EndDate <> 0D) THEN BEGIN
IF (EndDate >= StartDate) then
Record.SETRANGE("Posting Date", StartDate, EndDate)
ELSE
ERROR('End Date must be greater than Start Date');
END;
-Yogesh Kulkarni
Please verify, if you find answer helpful.
Could you please let us know what you have tried till now, we will help you to provide a solution if you are running into an issue and that will help you to learn, if you expect us to write the solution for you then you many not learn it.
Hi Jsshivalik,
Are you developing a report?
You can check Report 116, there is a function there called VerifyDates which is similar. They invoke it on Customer - OnPreDataItem but I think it could be better if the users would receive an error when they enter the dates.
You can create a function like this to check the dates:
LOCAL CheckDates() IF (StartDate = 0D) OR (EndDate = 0D) THEN EXIT; IF StartDate > EndDate THEN ERROR('Start Date: %1 is greater than End Date: %2', StartDate, EndDate);
Create two global variables for the dates and add them to the request page as fields, then you can use the OnValidate trigger for the fields to call your method.
Let's say your data item is Sales Invoice Headers, on the Sales Invoice Header - OnPreDataItem() you can do this for example:
IF (StartDate <> 0D) AND (EndDate <> 0D) THEN SETFILTER("Posting Date", '%1..%2', StartDate, EndDate); IF (StartDate <> 0D) AND (EndDate = 0D) THEN SETFILTER("Posting Date", '%1..', StartDate); IF (StartDate = 0D) AND (EndDate <> 0D) THEN SETFILTER("Posting Date", '..%1', EndDate);
André Arnaud de Cal...
292,516
Super User 2025 Season 1
Martin Dráb
231,430
Most Valuable Professional
nmaenpaa
101,156