Hi guys.
This have been buggin me.
A simple thing like changing a TextBox text when a DateField is empty or 0D.
I've tried two things (well not really, i've lost count but here's where i'm at now).
1) On the layout designer:
I've tried to write =IIF(Fields!PromisedDeliveryDate.Value = 0D, "Pre", "POST")
in the TextBox properties Visibility Expression. This makes sense to me. When PromisedDeliveryDate is 0D (empty) then i write PRE in the TextBox if not, i write POST. <-- Does not work as it returns a data type that it not valid (i guess there something about the Date datatyoe and Text here, i dont know).
2) In NAV using C/AL
- Created Variable: gReportTypeLbl Text 50.
- Created gReportTypeLbl in the Report Dataset Designer: DataSource: gReportTypeLbl Name: ReportTypeLbl.
- Added two Text Constants Text004(Order) and Text005(Pre-oder)
- C/AL written:
IF "Sales Header"."Promised Delivery Date" <> 0D THEN BEGIN
gReportTypeLbl := Text004;
END ELSE
gReportTypeLbl := gOrderTitelText;
The problem here is that i cannot populate the Textbox with my variable in the Layout designer (I can find the ReportTypeLbl thou).
Can anyone help? This seems to simple, yet i'm on day 3 now and have yet to make a simple text change if the date field is empty.
Thank You for your time
Answers
have you checked your dataset of your report?
you can do this by going to the about this report page (Ctrl+Alt + F1) when on the request page. if you then run the report and go to this page again you can see your dataset there.
there you can also see what the value is you need to check for in the IIF.
This IIF needs to be written in the expression of your textbox however, not in the visibility.
you are probably missing something in a grouping somewhere for option 2. This you can check in the dataset.
What version of nav are you using?
* Try With Message Type Below Your Code
* Like, Message(gReportTypeLbl);
2. Did you add gReportTypeLbl to DataSet? Is the value ok on "Preview DataSet"?
Maybe I didn't explain well enough. But I did solve it.
The changes needed are in the header. So the value it returned correctly in the dataset. But the header will not update when next i pressed in the navigation panel.
The solution is to add a TextBox to the body, which you then hide but give the value you want
to see in the Header. So I'm creating a Text variable called gReporTypeLbl and the TextBox properties for the textbox then =(Fields!greportTypeLbl.value).
I ended up using C/AL:
IF "Sales Header"."Promised Delivery Date" <> 0D THEN
gReportTypeLbl := TxtOrderNormal
ELSE
gReportTypeLbl := TxtOrderPre;
IF "Sales Header"."Promised Delivery Date" <> 0D THEN
gPreOrderStatement := ''
ELSE
gPreOrderStatement := TxtPreorderStatement;
And this works. Added on OnAfterGetRecord.
Thank you guys for answering my question