Question Status

Verified
THREEEA asked a question on 27 Aug 2014 11:22 AM

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?

Thank you

Reply
José Castro responded on 27 Aug 2014 2:35 PM

Hello Threeea,

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.

_________________

José Castro

http://msnav.es

Reply
THREEEA responded on 28 Aug 2014 1:54 AM

Thanks jose,

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?

Reply
Verified Answer
Natalie Karolak responded on 28 Aug 2014 1:59 AM

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)

Reply
THREEEA responded on 2 Sep 2014 5:01 AM

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.

Thank you!

Reply
Natalie Karolak responded on 2 Sep 2014 5:59 AM

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..))

THEN

  CurrReport.SKIP;

Reply
THREEEA responded on 2 Sep 2014 7:20 AM

Thank you that's very helpful!

Reply
Verified Answer
Natalie Karolak responded on 28 Aug 2014 1:59 AM

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)

Reply