Renaming Dimension Code in table Dimension Value

iqbalmadiqbalmad Member Posts: 179
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?

Comments

  • garakgarak Member Posts: 3,263
    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.

    regards
    Do you make it right, it works too!
  • iqbalmadiqbalmad Member Posts: 179
    hi garak

    shud i replace the MODIFY with RENAME(Code)??
  • garakgarak Member Posts: 3,263
    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!
  • iqbalmadiqbalmad Member Posts: 179
    thanks garak.. i now know how to use the RENAME function.. culdnt find a better explanation.
Sign In or Register to comment.