Rename Code FixAsset

Hi Everybody

 

I want rename Code (FA). I create 1 table name FA_Temp with 2 filed (FA Old, FA New). I create 1 report and write code rename Code FA on table Fix Asset (ID 5600). But it's not work.

Fixed Asset - OnAfterGetRecord()


IF FA_Temp.GET("No.") THEN BEGIN
    CodeFA:=FA_Temp."FA New";
    lRec_FixedAsset.RENAME(CodeFA);
END;

Please help me fix code. Thanks very much.

  • Do the following

    In the existing fixed asset table add a new field called New Fixed asset no., Update all the new fixed asset no. via a dataport.


    Create a new processing report with Integer with Maxiteration in property = 1

    Declare a variable TempFixedAsset Data type Record Fixed Asset (Make sure you set this to temporary in properties)
    Declare a variable FixedAsset Record FixedAsset
    Declare another variable NewFixedAsset Record Fixedasset

    OnAfterGetRecord
    clear(tempfixedasset);

    fixedasset.reset;
    if fixedasset.find('-') then begin
    repeat
    tempfixedasset.init;
    tempfixedasset.transferfields(fixedasset);
    tempfixedasset.insert;
    fixedasset.delete;
    until fixedasset.next = 0
    end;

    if tempfixedasset.findset then begin
    repeat
    fixedasset.reset;
    fixedasset.init;
    fixedasset.transferfields(tempfixedasset);
    fixedasset."no." := tempfixedasset."new fixed asset no.";
    fixedasset.insert;
    until tempfixedasset.next = 0
    end;
  • In reply to sbhatbng:

    Thanks sbhatbng reply.
    I have a question ? Can get new code form table created.

    Sample :
    - Table (New FA)
    1 Field : FAold
    2 Field : FANew
    -> variable TablenewFA
    SETRANGE(TablenewFA.FAOld, "Fixed Asset"."No.")

    I want get data form table New to Table "Fixed Asset"
    Thanks very much.
  • In reply to sbhatbng:

    sbhatbng, I follow your instructions. But it does not work

     

    Declare a variable TempFixedAsset Data type Record Fixed Asset (Make sure you set this to temporary =Yes in properties)
    Declare a variable FixedAsset Data type Record "Fixed Asset"
    Declare another variable NewFixedAsset Data type Record "Fixed Asset"

    CLEAR(TempFixedAsset);
    
    FixedAsset.RESET;
    IF FixedAsset.FIND('-') THEN BEGIN
    REPEAT
    TempFixedAsset.INIT;
    TempFixedAsset.TRANSFERFIELDS(FixedAsset);
    TempFixedAsset.INSERT;
    FixedAsset.DELETE;
    UNTIL FixedAsset.NEXT = 0
    END;
    
    IF TempFixedAsset.FINDSET THEN BEGIN
    REPEAT
    FixedAsset.RESET;
    FixedAsset.INIT;
    FixedAsset.TRANSFERFIELDS(TempFixedAsset);
    FixedAsset."No." := TempFixedAsset.NewCode;
    FixedAsset.INSERT;
    UNTIL TempFixedAsset.NEXT = 0
    END;

  • If you have 2 separate tables then you can use setrange and then get the No. and then insert the new no. while creating the Fixed Asset record.
Related