Renaming Dimension Code in table Dimension Value
iqbalmad
Member Posts: 180
Hi,
am running a batch report to modify the Dimension codes.
dataitem = Dimension Value
OnAfterGetRecord
IF "Dimension Code" = 'NATURE' THEN
BEGIN
IF STRLEN(Code) = 6 THEN
Code := STRSUBSTNO('%1%2%3',COPYSTR(Code,1,3),'0',COPYSTR(Code,4,3));
END;
MODIFY;
On running the report, i get an error like NATURE , 'XXX0XXX' does not exist.
Can you explain y?
am running a batch report to modify the Dimension codes.
dataitem = Dimension Value
OnAfterGetRecord
IF "Dimension Code" = 'NATURE' THEN
BEGIN
IF STRLEN(Code) = 6 THEN
Code := STRSUBSTNO('%1%2%3',COPYSTR(Code,1,3),'0',COPYSTR(Code,4,3));
END;
MODIFY;
On running the report, i get an error like NATURE , 'XXX0XXX' does not exist.
Can you explain y?
0
Comments
-
Yes we can explain.
You want to modify the CODE field. These field is a part of the primary key.
If you want to change the value of a primary key field, u must use the rename() function.RENAME (Record)
Use this function to change a primary key in a C/SIDE table.
[Ok]:= Record.RENAME(Value1, [Value2],...)
Ok
Data type: boolean
This tells you whether the system was able to rename the primary key or not. Typically, the system will return FALSE if the record does not exist or if you do not have permission to write to the table.
Record
Data type: record
The record that contains the primary key that you want to change.
Value1, Value2, ...
Data type: text
The new values for the primary key.
Comments
For example, if you use the customer's phone number as the customer number, you can use this function to change the customer number if the phone number changes.
regardsDo you make it right, it works too!0 -
hi garak
shud i replace the MODIFY with RENAME(Code)??0 -
rename needs all Primary key values
Like old records in table Dimension Value (DimValue)
DimensionValueCode,Dimensioncode
KST,789
KST,598
KTR,530
KTR,017
and the second record should be renamed to KST,999:
DimValue.get('KST',598);
DimValue.rename('KST',999);Do you make it right, it works too!0 -
thanks garak.. i now know how to use the RENAME function.. culdnt find a better explanation.0
Categories
- All Categories
- 75 General
- 75 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
- 610 NAV Courses, Exams & Certification
- 1.9K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 251 Dynamics CRM
- 103 Dynamics GP
- 6 Dynamics SL
- 1.5K Other
- 991 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 28 Design Patterns (General & Best Practices)
- Architectural Patterns
- 9 Design Patterns
- 4 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1K General Chat
- 1.6K Website
- 77 Testing
- 1.2K Download section
- 23 How Tos section
- 249 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions