Skip to main content

How to Recover Dimension Set Entry Table from Dimension Set Tree Node Table?

Hi,

Accidentally developer has forgot to set Temporary  = Yes for Record object of  Table 480 - "Dimension Set Entry".

He created record variable for table 480 - dimension set entry :
TempDimSetEntry - Record (Temporary = <No>)

Then executed standard GetDimneisonSet function:
DimMgt.GetDimensionSet(TempDimSetEntry,"Dimension Set ID");

And if run this code using developers license then it will delete all the records from Dimension Set Entr Table (because Temporary = False it should be True)

This happen in UAT database of customer than it start giving error everywhere in the system and this impacted our UAT Session.

But after analyzing and we found that we can create the dimension set entry from dimension set tree node table.

Below is the Batch report which we used to create the dimension set entries from dimension tree node table.

OBJECT Report 50000 CreateDimensionSetID
{
  OBJECT-PROPERTIES
  {
    Date=;
    Time=;
    Modified=Yes;
    Version List=;
  }
  PROPERTIES
  {
    Permissions=TableData 480=ri;
    ProcessingOnly=Yes;
    OnPostReport=BEGIN
                   Window.CLOSE;
                   MESSAGE('Done');
                 END;

  }
  DATASET
  {
    { 33027920;;DataItem;                    ;
               DataItemTable=Table481;
               DataItemTableView=SORTING(Parent Dimension Set ID,Dimension Value ID)
                                 WHERE(In Use=FILTER(Yes));
               OnPreDataItem=BEGIN
                               Window.OPEN(Text000);
                             END;

               OnAfterGetRecord=VAR
                                  DimensionSetEntry_lRec@33027921 : Record 480;
                                  LastID@33027922 : Integer;
                                BEGIN
                                  Window.UPDATE(1,"Dimension Set Tree Node"."Dimension Set ID");
                                  DimensionSetEntry_lRec.SETRANGE("Dimension Set ID","Dimension Set ID");
                                  IF NOT DimensionSetEntry_lRec.ISEMPTY THEN
                                    CurrReport.SKIP;

                                  TempDimSetTreeNode_lRecTmp.RESET;
                                  TempDimSetTreeNode_lRecTmp.DELETEALL;

                                  LastID := "Dimension Set Tree Node"."Parent Dimension Set ID";
                                  TempDimSetTreeNode_lRecTmp.Number := "Dimension Set Tree Node"."Dimension Value ID";
                                  TempDimSetTreeNode_lRecTmp.INSERT;
                                  WHILE LastID <> 0 DO BEGIN
                                    LastID := FindParentSetID(LastID);
                                  END;

                                  IF LastID = 0 THEN BEGIN
                                    TempDimSetTreeNode_lRecTmp.RESET;
                                    IF TempDimSetTreeNode_lRecTmp.FINDSET THEN BEGIN
                                      REPEAT
                                        DimensionValue_gRec.SETRANGE("Dimension Value ID",TempDimSetTreeNode_lRecTmp.Number);
                                        DimensionValue_gRec.FINDFIRST;
                                        DimensionSetEntry_lRec.INIT;
                                        DimensionSetEntry_lRec."Dimension Code" := DimensionValue_gRec."Dimension Code";
                                        DimensionSetEntry_lRec."Dimension Value Code" := DimensionValue_gRec.Code;
                                        DimensionSetEntry_lRec."Dimension Set ID" := "Dimension Set Tree Node"."Dimension Set ID";
                                        DimensionSetEntry_lRec."Dimension Value ID" := DimensionValue_gRec."Dimension Value ID";
                                        DimensionSetEntry_lRec.INSERT;
                                      UNTIL TempDimSetTreeNode_lRecTmp.NEXT = 0;
                                    END;
                                  END;
                                END;

               ReqFilterFields=Dimension Set ID }

  }
  REQUESTPAGE
  {
    PROPERTIES
    {
    }
    CONTROLS
    {
    }
  }
  LABELS
  {
  }
  CODE
  {
    VAR
      TempDimSetTreeNode_lRecTmp@33027920 : TEMPORARY Record 2000000026;
      DimSetEntry_gRec@33027922 : Record 480;
      DimensionValue_gRec@33027921 : Record 349;
      Window@33027923 : Dialog;
      Text000@33027924 : TextConst 'ENU=#1###############';

    PROCEDURE FindParentSetID@33027923(SetEntryNo@33027920 : Integer) : Integer;
    VAR
      DimSetTreeNode_lRec@33027921 : Record 481;
    BEGIN
      DimSetTreeNode_lRec.SETRANGE("Dimension Set ID",SetEntryNo);
      DimSetTreeNode_lRec.FINDLAST;
      TempDimSetTreeNode_lRecTmp.Number := DimSetTreeNode_lRec."Dimension Value ID";
      TempDimSetTreeNode_lRecTmp.INSERT;
      EXIT(DimSetTreeNode_lRec."Parent Dimension Set ID");
    END;

    BEGIN
    END.
  }
  RDLDATA
  {
  }
}

Comments

Popular posts from this blog

AL Development 03 - How to Develop New Report in AL?

Hi Readers, Now its time to develop the most important part of Navision which client desire the most yes you are correct i am talking about Reports. As we know to develop any solution in Business Central we must start working on AL Code Extension so from this blog you will get to know the detailed step how to create a Report through AL Code in business Central. Note: As of now there is no provision to customise the base report. Let’s try to create a simple report. Add new file with .al extension in your project folder through visual studio code My File Name is My_report.al  Code Snippet for adding a new Report, use snippet treport as shown below: Next Step to set these Report Properties - • Assign ID and Provide a name of the Report that you are adding. • Set UsageCategory to ReportsAndAnalysis. • Set ApplicationArea to All. As you select the treport snippet then a default structure of the report is created as below: Basically, there are 3...

Custom sheet name in RDLC Reports

Hi Readers, In this article we are going to discuss how to change the excel sheet name while using base Navision SAVEASEXCEL functionality. Applicable for RDLC reports of Navision and SSRS reports. Let’s say we have the following report that shows total sales by product category by territory:   When we export this report to Excel, we’d like each territory to appear in its own worksheet and each worksheet named after its territory: How do we make this work? Easy! 1) Put every group on its own page. 2) name each page using the same field the group uses. Step 1: Put each group on its own page To put each group on its own page, open the group’s property window. Then, in the Page Breaks category, put a check mark in the Between each instance of a group check box. Click OK to complete this step. Step 2: Name the pages of the group With the group selected in the Row Group s panel, press F4 to open the Properties window. Next, expand the Group ...

AL Development 01 - How to Develop New Table in Database?

Hello readers, As we know to develop any solution in Business Central we must start working on AL Code Extension so from this blog you will get to know the detailed step how to create a table through AL Code in business Central. Requirement : Need to create a new table with below fields: Now let’s Start: Try to keep a naming standard for your projects; As I am using the combination of Table description +Table-ID, you can use your own naming convention. So, my table file name is: My_Table50129.al AL provides a list of the snippets to make it easy for developers to add objects in extension. Snippet for getting a table layout use snippet ttable (here we have to t as prefix for every type of object we want to create in AL) as shown below: Now Assign the ID and name of the table as below: As you select the ttable from the list a default table design structure is created as shown below: You can divide the whole table into 4 Sections - · F...