Set Posting Date filter on a request page.

Hello,

I have created a report based on cust. ledger entry table. Now I need to set a filter on request page i.e. Posting Date(From Date, To Date) . And also if a user leaves those fields empty then he will get an error msg and does not leave the page. How can I do it…Plz help…!!

On the DataItem On PreSection Add

IF StartDate = 0D or EndDate = 0D THEN
ERROR(‘Start Date and EndDates are Mandatory’);

SETRANGE(“Posting Date”,StartDate,EndDate);

Hi,
Will surely help you out, but first tell us what you have tried and where are you getting issues.
Dont take it otherwise Just to understand that you tried something.

Should I use SETRANGE or I must use SETFILTER.I’m confuse a bit.if U can send me the entire code than It’ll be very much helpful to me…Thanks!!

Sir,
After using this code I’m getting an error. It says ‘Type conversion is not possible because 1 of the operators contains an invalid type’.
‘Date OR Date’. Please suggest what should I do??

Hi Rajat
There are many situations, like if you want a simple filter then go for SETRANGE which is Closed Filter As it contains Start and End…
For Complex situation go for Setfilter…

IN your case there let say if you just want to show error message you can get that by just writing some Code on
OnPreReport()–Trigger
IF StartDate = 0D OR EndDate = 0D THEN
ERROR(‘Start Date and EndDates are Mandatory’); // As suggested like Rockwithnav

Note :what if user need’s all records until to specific date he doesn’t want to give starting date … then SETFILTER comes in SETFILTER(“Posting Date”,’…%1’,EndDate);

1 Like

Hey Friend,

Just put the variables in Bracket like this

IF (StartDate = 0D) OR (EndDate = 0D) THEN
ERROR();

NAV Compiler interprets whole line as a single statement, now you wont get this Error. :slight_smile:

Please check standard report 14