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

Improved performance features of Business Central 17

  In the training I’ve done to some partners last week, when talking about performances I shared an example of an extension with 3 features that I think are not so well known but that have a significant impact on how your code performs, expecially on a SaaS environment. That extension used the following features: Partial record loading Temporary Tables QueryCategory The  Partial record  capability  is a new feature available starting from Dynamics 365 Business Central 2020 Wave 2 (v17) and I think it’s one of my top personal desiderata from years. This feature permits you to load only the needed fields of a recordset (when accessing a data source) instead of loading the entire set of fields. This is particularly useful on reports and OData pages because you can avoid to do a SELECT * (plus JOINS with all the extension’s tables) and instead doing a SELECT of only the fields you need. Now you can do something like: procedure TestPartialRecord(): Decimal ...

🧾 Understanding Interfaces in Business Central (With Real-Life Example)

💡 A Simple Guide for Beginners If you're learning Microsoft Dynamics 365 Business Central , one concept that often feels confusing at first is Interfaces . But don’t worry — let’s break it down in simple, real-world language so you can understand not just what interfaces are, but why they matter . 🧠 The Problem We Face in Real Projects Imagine you’re building a payment system in Business Central. Your company accepts: 💳 Credit Card 📱 UPI 🏦 Bank Transfer At first, a simple approach looks like this: if PaymentType = 'Card' then     ProcessCard() else if PaymentType = 'UPI' then     ProcessUPI() else if PaymentType = 'Bank' then     ProcessBank(); ✅ Works fine… for now. 🚨 But Here’s What Happens Later As your system grows: New payment types get added (PayPal, Wallet, etc.) Code becomes longer and harder to read Every change requires modifying existing logic Risk of breaking existing functionality increases 👉 This is where interfaces come to...

UPGRADE CUSTOMIZATIONS TO V2 EXTENSION (Application and Data)

From Navision 2018 Onwards, Navision only support v2 Extension. Dynamic Navision Extension will make upgrade easier. If customizations are converted into V2 extension that means v2 Extension consist upgraded Data as well as customizations, also it will be easy to upgrade into new version of Navision and apply CU updates. Below are the detailed steps to upgrade customizations into Navision 2018 v2 Extensions .  1) you have Customized database in Microsoft Dynamics Navision 2018. 2) Create the new table for each table that is customized or also for customized field in standard table but while creating table for standard table, add the primary key and customized field with same ID and Name in new table. For E.g.: I have created 1 table “Person” and 2 Customized Field (Test, Doc No) in “Sales Header”. Now create 2 New tables in 2018.  · Upg Sales Header -> Two base field (PK) and customized field -> Same ID and add primary key. Refer be...