I am trying to create an expression on a sales quote report for the 'hidden' property in visual studio - to hide lines of the quote according to what I specify.
I am using the 'iif(' function which is fine for some things, but also need to show/hide based on whether the sales line type is 'item' or 'resource' and it seems to need a Boolean rather than specifying 'iif(saleslinetype=resource)'.
How can I show/hide the lines I need based on sales line type?
One of the easiest ways (although I'll admit not the most elegant one) would be to just have a boolean var in NAV that after getting the record checks for that condition and send that very same var to the report. That way you can use that var which is a Boolean for the property instead of trying to use the type field.
But I wanted to avoid having to do this if possible - does anyone know of anything you can do in the expression string or anything?
Whenever possible, do not pass unneccessary records to RDLC. You can skip those records already in C/AL data items according to current user settings, using the CurrReport.SKIP command.
Talking about iif: Which data type is required by RDLC, depends only on how the value is passed to RDLC. Thus: you decide already in C/AL.
When passing option values, it is always best to pass option values as numbers to ensure multilanguage functionality. In order to pass an option value as integer, replace in C/AL SourceExpr SalesLine.Type with FORMAT(SalesLine.Type,0,2). The only disadvantage of passing as integer: it's quite hard to read in RDLC as you will need to know which integer represents which option value.
In order to hide an element in RDLC, it is not strictly necessary to write an iif statemnt. Just formulate the expression so that it answeres the question: WHEN must be this element hidden? So, instead of =iif(Fields!SalesLineType.Value = 3) you can just write =Fields!SalesLineType.Value = 3. If it needs to be hidden in case of two possible values: =(Fields!SalesLineType.Value = 3) OR (Fields!SalesLineType.Value = 1)
Thank you Natalie this is very helpful.
Please could you help with the CurrReport.SKIP command? - on the sales quote report, where in the C/AL code should this be inserted and are you able to give me an example of how to write it? I have multiple options - ie hide if a and b and c are true, or also hide if x and y and z are true.
Go to data item RoundLoop, trigger OnAfterGetRecord.
After the third line (SalesLine.NEXT;) insert new lines:
IF ((A..) AND (B...) AND (C..)) OR
((X..) AND (Y...) AND (Z..))
Thank you that's very helpful!