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

Community site session details

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

Combining the values of 2 fields into one new column

(0) ShareShare
ReportReport
Posted on by 105

Hi Guys,

I have made a new table extension and added a new field Ship to External No:

        field(50003; TBLSHP_ExternalNo; Text[30])
        {
            Caption = 'Ship-to External No.';
        }

However what i want to do now is to get the value of 2 existing fields and combine them as the value of the new table.

For example the current values of the fields are:

Thus the value of the new field "Ship To External No" must reflect "01121212-002"

How can one achieve this?

Thanks

I have the same question (0)
  • Verified answer
    Nitin Verma Profile Picture
    21,698 Moderator on at
    RE: Combining the values of 2 fields into one new column

    Hi,

    You should call those events for your table in the codeunit or you can write the below code On OnInsert trigger and OnModify Trigger as well.

    [EventSubscriber(ObjectType::Table, database::"YourTable", 'OnAfterInsertEvent', '', true, true)]

       local procedure OnAfterInsertEvent_YourTable(var Rec: Record "YourTable")

       begin

           if (rec."Customer No." <> '') and (rec.code <> '') then

               rec."External Document No." := rec."Customer No." + ' ' + rec.Code;

       end;

       [EventSubscriber(ObjectType::Table, database::"YourTable", 'OnAfterModifyEvent', '', true, true)]

       local procedure OnAfterModifyEvent_YourTable(var Rec: Record "YourTable")

       begin

           if (rec."Customer No." <> '') and (rec.code <> '') then

               rec."External Document No." := rec."Customer No." + ' ' + rec.Code;

       end;

  • Suggested answer
    Abz Profile Picture
    9 on at
    Combining the values of 2 fields into one new column
    Or you can make the source a function (which always returns the combination of the two fields)
     
    field(50003; TBLSHP_ExternalNo; GetCustNoAndCode())
     
            {
     
                Caption = 'Ship-to External No.';
     
            }
     
    local procedure GetCustNoAndCode(): Text
    begin
         exit(format(Rec."Customer No" + Rec.Code));
    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

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 3,377

#2
Jainam M. Kothari Profile Picture

Jainam M. Kothari 2,696 Super User 2025 Season 2

#3
YUN ZHU Profile Picture

YUN ZHU 1,512 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans