Skip to main content

Notifications

Business Central forum
Answered

How to add a value from a custom field to an existing field

Posted on by 382

Hey everyone, 

I have created a custom field into an existing table. I want that whenever a value is inserted to the custom field, the same value should be inserted into one of the specified existing field. Like for example in the figure below, for a specific "No." when "Net change" is 749259.10  then "Budgeted Amount" should also become 749259.10. Remember, I don't want it for the entire column but for a specific "No.". Kindly address my concern. Thank you.

pastedimage1669885944459v1.png

Categories:
  • RE: How to add a value from a custom field to an existing field

    Ok. Thanks all for the answers.

  • Sejal Profile Picture
    Sejal 95 on at
    RE: How to add a value from a custom field to an existing field

    Hello,

    You Modify "Net Change" field

    Try below code,

    Modify("Net Change")

    {

           trigger OnAfterValidate()

          var

         begin

         rec."Budgeted Amount" := Rec."Net Change";

         End;

    }

    Thanks

  • Verified answer
    YUN ZHU Profile Picture
    YUN ZHU 69,612 Super User 2024 Season 2 on at
    RE: How to add a value from a custom field to an existing field

    No, this is not possible.

    FlowFields are not physical fields that are stored in the database. 

    https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/devenv-flowfields

    pastedimage1669941667763v1.png

  • RE: How to add a value from a custom field to an existing field

    Is there any way to add a custom value in a flow field?

  • Suggested answer
    Nitin Verma Profile Picture
    Nitin Verma 21,023 Moderator on at
    RE: How to add a value from a custom field to an existing field

    Hi,

    You can not assign any value to or from of those fields as those fields are Flowfields in the table. Also if you want to you can introduce your custom field and do the following

    Rec.calcfields("net Change");

    Custfield := Rec."Net Change";

    This is an idea but use calcfields for fields.

    Thanks.

  • RE: How to add a value from a custom field to an existing field

    it is not working. I have attached the screenshots. You can validate whether it is correct or not and if not then provide me with your code. The EventSubscriber must be in code that's why I have created one. Thank you.

    pastedimage1669891992199v1.png

    pastedimage1669892009606v2.png

  • Suggested answer
    DAnny3211 Profile Picture
    DAnny3211 9,217 Moderator on at
    RE: How to add a value from a custom field to an existing field
    Hi
    hook into the onbeforeValidate event of the Net Change field and insert the following code:
     [EventSubscriber(ObjectType::Table, yourtable, 'OnBeforeValidateEvent', 'Net Change', false, false)]
        local procedure fsfd(var Rec: Record yourtable)
        begin
           rec.Budgeted Amount:=rec.Net Change;
        end;
    check my answer if it helped you, thanks
    DAniele

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

Anton Venter – Community Spotlight

Kudos to our October Community Star of the month!

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Dynamics 365 Community Newsletter - September 2024

Check out the latest community news

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,524 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,469 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans