NAV 2013: use default function in layout code

Hello

please i want to know if it is possible to use the defaut system function in a report layout code section (customize code)
for example how in the report layout code section (customize code) how to use the default function CountDistinct
who can be use in a textbox expression
Thanks

138

Hey Lornisse,

You just nee to write CountDistinct(Fields!X.Value), it will return the count of Distinct Values.

Hi,
Yes you can use these functions. Just for an example below is a scenario which you can test -

  1. Create a Report with Table as Item Ledger Entry with Fields Item No and Location Code.
  2. Create a Table in Layout, Add fields in Body Section of the table.
  3. Add a Row outside Group (Table Footer).
  4. add following expression in Table Footer -
    =CountDistinct(Fields!ItemNo_ItemLedgerEntry.Value)
    &
    =CountDistinct(Fields!LocationCode_ItemLedgerEntry.Value)

Where -

Fields!ItemNo_ItemLedgerEntry.Value = Dataset Field Name for Item.

Fields!LocationCode_ItemLedgerEntry.Value = Dataset Field Name for Location.

Run the Report you will see the Unique Item No and Location Count in the Table Footer.

ok but if i want to know the CountDistinct to know the number of distinct value of a field in a group in the code section of the report layout
for example CountDistinct(Fields!LineNo_SalesInvLine.Value,“LinesGroup”) where LinesGroup is the name of a group in the report layout
Thinks

Yes you can do that too.
Did you tired that, if yes what is the issue.

Thank you
it is correct and work but if i want to use the CountDistinct function in the code section (custom code section = report properties code section ) and not in the body
it is possible ?

Right click → properties → code (in the report layout)

540

Hey Lornisse,

Custom Code of the Report Property is used to built your own logic and get it used in the Report, you cant used the Standard Keywords there which you find when you are writing any expressions. If you want to build some custom logic you are free to write there and get it used with Code.YourFunctionName but you cant use the standard keywords while building your own Custom Code in the Report Property Code area.

Hope this Helps

Thank you
it is correct and work but if i want to use the CountDistinct function in the code section (custom code section = report properties code section ) and not in the body of a report layout it is possible ?

Right click → properties → code (in the report layout)

626

thank you very much
you answer is clean (clear)

HI,
I think RockWithNAV answered your question, please mark the thread as resolved after selecting the verified answer.

HI,

Please do not duplicate the questions in forum. This question seems a duplicate question in below link -
dynamicsuser.net/…/477831

I think RockWithNAV answered your question, please mark the thread as resolved after selecting the verified answer.

Hello

please i want to know if it is possible to use the defaut system function in a report layout code section (customize code)
for example how in the report layout code section (customize code) how to use the default function CountDistinct
who can be use in a textbox expression
Thanks

117