Skip to main content

Notifications

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!

  • Community Member Profile Picture
    on at
    RE: Updating a FlowField after related field is modified

    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?

  • Verified answer
    YUN ZHU Profile Picture
    81,365 Super User 2025 Season 1 on at
    RE: Updating a FlowField after related field is modified

    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

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Jonas ”Jones” Melgaard – Community Spotlight

We are honored to recognize Jonas "Jones" Melgaard as our April 2025…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 294,101 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 232,866 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,158 Moderator

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans