web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

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

Updating a FlowField after related field is modified

(0) ShareShare
ReportReport
Posted on by

I've created a custom table with 2 fields - One is a lookup to the Customers table, the other is a FlowField that displays the name of the customer selected in first field.

        field(18; Customer; Code[20])
        {
            DataClassification = ToBeClassified;
            Caption = 'Customer No.';
            TableRelation = Customer."No.";
        }
        field(19; CustomerName; Text[250])
        {
            Caption = 'Customer';
            FieldClass = FlowField;
            CalcFormula = lookup(Customer.Name where("No." = field(Customer)));
        }

Both fields work correctly, however I'm noticing that if I change the Customer No selected in the first field, the second field doesn't display an updated name until I close and reopen the record.

My question is how can I update the Customer Name field every time the Customer No. is changed, without having to reopen the page? I'm assuming I should utilize the OnModify function but can't quite figure it out.

Thanks!

I have the same question (0)
  • Verified answer
    YUN ZHU Profile Picture
    95,763 Super User 2025 Season 2 on at

    Hi, please don't use flowfield, try the following code.

            field(50100; Customer; Code[20])
            {
                DataClassification = CustomerContent;
                Caption = 'Customer No.';
                TableRelation = Customer."No.";
    
                trigger OnValidate()
                var
                    Cust: Record Customer;
                begin
                    if Cust.Get(Customer) then
                        CustomerName := Cust.Name;
                end;
            }
            field(50101; CustomerName; Text[250])
            {
                DataClassification = CustomerContent;
                Caption = 'Customer';
                Editable = false;
            }

    pastedimage1643328385034v1.png

    Hope this will help.

    Thanks.

    ZHU

  • Community Member Profile Picture
    on at

    I have found my issue: I reused the 'Job' object. I have changed this value and everything works well.

    Zhu - you continue to come to my rescue, thank you!

    Your suggestion fixed this problem, however I am trying to use the same logic for a similar issue and it does not work.

    I have created a field on the Job card.

    tableextension 50103 AddJobFields extends Job
    {
        fields
        {
            field(50103; AddressStreet; Text[250])
            {
                DataClassification = ToBeClassified;
                Caption = 'Street';
            }
        }
    }

    In my new table, I have added 2 fields. The first is a lookup to Jobs, and the second is a textbox that should display the related Jobs 'AddressStreet' field that I created above.

            field(2; Job; Code[20])
            {
                DataClassification = CustomerContent;
                Caption = 'Job';
                TableRelation = Job."No.";
    
                trigger OnValidate()
                var
                    Job: Record Job;
                begin
                    if Job.Get(Job) then
                        AddressStreet := Job.AddressStreet;
                end;
            } 
            
            field(3; AddressStreet; Text[250])
            {
                DataClassification = CustomerContent;
                Caption = 'Street';
                Editable = false;
            }

    I would expect this work, however when I set a value in the Job field, I get the error

    Validation Results

    The length of the string is 224, but it must be less than or equal to 20 characters. Value: Open Never {00000000-0000-0000-0000-000000000000} Fixed FCY Fixed FCY No No No Per Job No {00000000-0000-0000-0000-000000000000} No 0 0 0 0 No 0 0 0 0 0.

    Why would this be happening?

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,116

#2
Khushbu Rajvi. Profile Picture

Khushbu Rajvi. 764 Super User 2025 Season 2

#3
YUN ZHU Profile Picture

YUN ZHU 635 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans