Skip to main content

Notifications

Small and medium business | Business Central, N...
Answered

Combining the values of 2 fields into one new column

(0) ShareShare
ReportReport
Posted on by 54

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

  • Suggested answer
    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;
  • Verified answer
    Nitin Verma Profile Picture
    Nitin Verma 21,085 Super User 2024 Season 1 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;

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 Our 2025 Season 1 Super Users!

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

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,979 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,848 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans