Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Answered

Unable to update field data value from one table to another table.

(0) ShareShare
ReportReport
Posted on by 387

Dear Experts,

I have created a new entry form where have a field name is "FA Status"...here data is managed through line no. I have added the release and reopen button in ribbon section. I want to update the last "FA status" from this card to Fixed Asset card.

I have write the code in newly customized table field on Validate, but there is no effect. please help me to resolve it.

My code is below.

Fa Status - OnValidate()
IF Status=Status::Released THEN BEGIN
FixedAsset.RESET;
IF FixedAsset.FINDLAST THEN
REPEAT
IF Reco.GET(FixedAsset."Fa Status") THEN
FixedAsset."Fa Status":=Reco."Fa Status";
FixedAsset.MODIFY;
UNTIL FixedAsset.NEXT = 0;
END;

  • navision begginers Profile Picture
    387 on at
    RE: Unable to update field data value from one table to another table.

    thank you very much....unfortunately I was written my code on wrong places...i  need to write the code on

    Status - OnValidate().

    Resolved,

  • navision begginers Profile Picture
    387 on at
    RE: Unable to update field data value from one table to another table.

    I have tried with same..but unable to update the FA card - FA Status field. I have attached the screenshot the relation between Fixed Asset table and newly customized table (Reco).

    5516.png

    3324.png

  • Verified answer
    Binesh Profile Picture
    7,885 on at
    RE: Unable to update field data value from one table to another table.

    1. in the SETRANGE, Reco.Code as you have written, I guess which was blank.

    2. As I mentioned, Get work based on Primary Key, and as per your screenshot, you have declared "type", Code, "Line No.".

    So You have to pass the all the 3 values for Get method.

    3. you are in the Reco Page then why are you again call the get, directly you can update the last  FA value.

    IF Status=Status::Released THEN BEGIN
        FixedAsset.RESET;
        FixedAsset.SETRANGE("No.", Code);
        IF FixedAsset.FINDLAST THEN
            IF FixedAsset."Fa Status" <> "Fa Status" THEN BEGIN
                FixedAsset."Fa Status":= "Fa Status";
                FixedAsset.MODIFY;
            END;
    END;

    Still if you are not getting the expected result then, Share the Reco and Fixed Asset data, also let us know the link between reco and Fixed Asset.

  • navision begginers Profile Picture
    387 on at
    RE: Unable to update field data value from one table to another table.

    Thank you for your reply sir. I have updated my code...but still it is not working. I have send the screenshot.

    7282.png

    6278.png

    0358.png

    2804.png

  • Suggested answer
    Binesh Profile Picture
    7,885 on at
    RE: Unable to update field data value from one table to another table.

    Hello,

    Your code is not clear, I do not have your table architecture so I am giving you some suggestions.

    GET is working on primary Key.

    If you need to update all the records then use below format, it would be more faster than you written.

    IF Status=Status::Released THEN BEGIN
        FixedAsset.RESET;
        //Also use filter here based on relation between fixedAsset and Your table
        //You can remove the Repeat until if single record needs to update.
        IF FixedAsset.FINDSET THEN
            REPEAT
                //Your Statement, for example
                IF Customer.GET('10000') THEN BEGIN
                   Customer.Address := 'New Address 12345';
                   Customer.Modify();
                END;
            UNTIL FixedAsset.NEXT = 0;
    END;

    What is the primary Key fields of Reco? 

    Repeat Until is used for get/update set of records based on filter criteria and you have mentioned you want only last record.

    rewrite your code by filtering the Fixed Asset records as shown below.

    Still if you have doubt then share your Tables fields with relations and some data so that I can check and update.

    IF Status=Status::Released THEN BEGIN
        FixedAsset.RESET;
        FixedAsset.SETRANGE(LinkField, LinkedValue);
        IF FixedAsset.FINDLAST THEN BEGIN
            //Your Statement for example
           FixedAsset."FA Status" := "FA Status";
           FixedAsset.Modify();
        END;
    END;

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
Sohail Ahmed Profile Picture

Sohail Ahmed 874

#2
YUN ZHU Profile Picture

YUN ZHU 829 Super User 2025 Season 1

#3
Mansi Soni Profile Picture

Mansi Soni 595

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans