How to add a Dimension to an existing Dimension Set for the G/L Entries
colingbradley
Member Posts: 162
I have a request to populate the entries for the previous 3 months with a new Dimension CUSTDIM
All the Customers have a default dimension = to the Customer No.
It seems I need to create a new dimension set ID for each new instance, the existing entries have 2 dimensions and will end up with 3, the G/L Entry will have a new Dimension Set ID.
My code works (a report) for a single G/L Entry but if I use the Document No. as the filter when running the report (3 G/L Entries), I get an error.
"The Dimension Set Entry already exists. Identification fields and values: Dimension Set ID='3596', Dimension Code='Project''."
Report
DataItemTable G/L Entry
SORTING(Entry No.) WHERE(Source Type=CONST(Customer))
G/L Entry - OnAfterGetRecord()
CLEAR(Dimvalue);
GLEntry.GET("Entry No.");
IF GLEntry."Source No." <> '' THEN BEGIN
// Get current DimSet entries
DimMgt.GetDimensionSet(TmpDimensionSetEntry,GLEntry."Dimension Set ID");
IF Dimvalue.GET('CUSTDIM',GLEntry."Source No.") THEN BEGIN
// check if CUSTDIM exists
TmpDimensionSetEntry.SETRANGE("Dimension Code",Dimvalue."Dimension Code");
IF TmpDimensionSetEntry.FIND('-') THEN
CurrReport.SKIP;
// Add CUSTDIM
TmpDimensionSetEntry.INIT;
TmpDimensionSetEntry."Dimension Code" := Dimvalue."Dimension Code";
TmpDimensionSetEntry."Dimension Value Code" := Dimvalue.Code;
TmpDimensionSetEntry."Dimension Value ID" := Dimvalue."Dimension Value ID";
TmpDimensionSetEntry.INSERT;
// create a new entry in Table 480
GLEntry."Dimension Set ID" := DimMgt.GetDimensionSetID(TmpDimensionSetEntry);
GLEntry.MODIFY;
END;
END;
TmpDimensionSetEntry.DELETE;
All the Customers have a default dimension = to the Customer No.
It seems I need to create a new dimension set ID for each new instance, the existing entries have 2 dimensions and will end up with 3, the G/L Entry will have a new Dimension Set ID.
My code works (a report) for a single G/L Entry but if I use the Document No. as the filter when running the report (3 G/L Entries), I get an error.
"The Dimension Set Entry already exists. Identification fields and values: Dimension Set ID='3596', Dimension Code='Project''."
Report
DataItemTable G/L Entry
SORTING(Entry No.) WHERE(Source Type=CONST(Customer))
G/L Entry - OnAfterGetRecord()
CLEAR(Dimvalue);
GLEntry.GET("Entry No.");
IF GLEntry."Source No." <> '' THEN BEGIN
// Get current DimSet entries
DimMgt.GetDimensionSet(TmpDimensionSetEntry,GLEntry."Dimension Set ID");
IF Dimvalue.GET('CUSTDIM',GLEntry."Source No.") THEN BEGIN
// check if CUSTDIM exists
TmpDimensionSetEntry.SETRANGE("Dimension Code",Dimvalue."Dimension Code");
IF TmpDimensionSetEntry.FIND('-') THEN
CurrReport.SKIP;
// Add CUSTDIM
TmpDimensionSetEntry.INIT;
TmpDimensionSetEntry."Dimension Code" := Dimvalue."Dimension Code";
TmpDimensionSetEntry."Dimension Value Code" := Dimvalue.Code;
TmpDimensionSetEntry."Dimension Value ID" := Dimvalue."Dimension Value ID";
TmpDimensionSetEntry.INSERT;
// create a new entry in Table 480
GLEntry."Dimension Set ID" := DimMgt.GetDimensionSetID(TmpDimensionSetEntry);
GLEntry.MODIFY;
END;
END;
TmpDimensionSetEntry.DELETE;
Experience is what you get when you hoped to get money
0
Best Answer
-
That worked, many thanksExperience is what you get when you hoped to get money0
Answers
-
Please try CLEAR(TmpDimensionSetEntry) instead of TmpDimensionSetEntry.DELETE0
-
That worked, many thanksExperience is what you get when you hoped to get money0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.7K Microsoft Dynamics NAV
- 18.8K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 333 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions