Options

How to Show Dimension Names in Report?

jeniezjeniez Member Posts: 25
Hi,

I added a dimension field to a report, but it only shows the Dimension Code in that field. How do I change it to show the Dimension Name instead?

I'm very new to the technical part of Navision, so please give me step-by-step instructions. Thank you.

Comments

  • Options
    AlbertvhAlbertvh Member Posts: 516
    Hi
    You will have to define 2 variables of DataType Record
    Dimension subtype Dimension
    DimValue subtype Dimension Value

    In the OnAfterGetRecord function you would have to add code
    eg
    DimName := '';
    DimValName := '';
    IF Dimension.GET("Global Dimension 1 Code") THEN
    DimName := Dimension.Name;
    IF DimValue.GET("Global Dimension 1 Code","Global Dimension 2 Code") THEN
    DimValName := DimValue.Name;

    I am assuming that DimName and DimValName are declared as Text variables and that you have put them into the Body Section of your report.

    Cheers
    Albert
  • Options
    jeniezjeniez Member Posts: 25
    Thank you for your reply but I'm still having some trouble. If I set the 2 variables as text, then I can't choose the subtype column. Should I set the variables as record instead. And when I used your code, and tried to run it, it said "You have specified an unknown variable- Dimension - Define the variable under 'Global C/AL symbols".

    As for your code, I just copied and paste it. Should I change some part or add something in the quotation?

    Sorry, I've never had any training on codes or on this part of Navision, so I have no clues on what to do. Thanks again for your helps.
  • Options
    AlbertvhAlbertvh Member Posts: 516
    Hi
    I have written a little report which shows only dimension 1 and 2 code names
    OBJECT Report 50116 TestReport
    {
      OBJECT-PROPERTIES
      {
        Date=01/06/05;
        Time=13:34:47;
        Modified=Yes;
        Version List=;
      }
      PROPERTIES
      {
      }
      DATAITEMS
      {
        { PROPERTIES
          {
            DataItemTable=Table36;
            DataItemTableView=SORTING(Document Type,No.)
                              WHERE(Document Type=FILTER(Invoice));
            OnPreDataItem=BEGIN
                            GLSetup.GET;
                          END;
    
            OnAfterGetRecord=BEGIN
                               DimName := '';
                               DimValName := '';
                               IF DimValue.GET(GLSetup."Shortcut Dimension 1 Code","Shortcut Dimension 1 Code") THEN
                                 DimName := DimValue.Name;
                               IF DimValue.GET(GLSetup."Shortcut Dimension 2 Code","Shortcut Dimension 2 Code") THEN
                                 DimValName := DimValue.Name;
                             END;
    
          }
          SECTIONS
          {
            { PROPERTIES
              {
                SectionType=Body;
                SectionWidth=12000;
                SectionHeight=846;
              }
              CONTROLS
              {
                { 1000000000;TextBox;150  ;0    ;1500 ;423  ;SourceExpr="Shortcut Dimension 1 Code" }
                { 1000000002;TextBox;6562 ;0    ;1500 ;423  ;SourceExpr="Shortcut Dimension 2 Code" }
                { 1000000004;TextBox;1746 ;0    ;4780 ;423  ;SourceExpr=DimName }
                { 1000000005;TextBox;8202 ;0    ;3775 ;423  ;SourceExpr=DimValName }
              }
               }
          }
           }
      }
      REQUESTFORM
      {
        PROPERTIES
        {
          Width=9020;
          Height=3410;
        }
        CONTROLS
        {
        }
      }
      CODE
      {
        VAR
          GLSetup@1000000004 : Record 98;
          DimValue@1000000001 : Record 349;
          DimName@1000000002 : Text[80];
          DimValName@1000000003 : Text[80];
    
        BEGIN
        END.
      }
    }
    
    

    I made the assumption that you only use 2 dimensions. If you use more then you will have to use the Document Dimension, Posted Document Dimension or Ledger Entry Dimension tables.
    You can copy and paste the above into a text file and import into Navision, be sure that you don't have a report with ID 50116

    Hope this helps

    Albert
Sign In or Register to comment.