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

Replicate same data fields

(0) ShareShare
ReportReport
Posted on by 95

Hello Dynamics Community. 

I'm new at business central. I have been given an assignment where I need to create a card where there are some fields which need to be filled and through an action when I click on it, the same data filled in this card is replicated automatically in an another card with the same fields there. 

It is the same process like  when we are doing a sales invoice we need to fill customer details and when we click on the post action, all the data filled here is replicated automatically in the posted sales invoice with the same fields there.

Will be grateful if someone could share some screenshots where could I find the specific code for this.

Thanks. 

I have the same question (0)
  • Suggested answer
    JAngle Profile Picture
    133 on at

    The Sales Header table has a function for copying over the customer details to a sales document. The function is called OnValidate of the Sell-to Customer No. 

    This is the code from that procedure for you to sample. Note that a function is run before this to GetCustomer so that you have the parameter to pass in

    local procedure CopySellToCustomerAddressFieldsFromCustomer(var SellToCustomer: Record Customer)
    begin
    "Sell-to Customer Template Code" := '';
    "Sell-to Customer Name" := Cust.Name;
    "Sell-to Customer Name 2" := Cust."Name 2";
    "Sell-to Phone No." := Cust."Phone No.";
    "Sell-to E-Mail" := Cust."E-Mail";
    if SellToCustomerIsReplaced or ShouldCopyAddressFromSellToCustomer(SellToCustomer) then begin
    "Sell-to Address" := SellToCustomer.Address;
    "Sell-to Address 2" := SellToCustomer."Address 2";
    "Sell-to City" := SellToCustomer.City;
    "Sell-to Post Code" := SellToCustomer."Post Code";
    "Sell-to County" := SellToCustomer.County;
    "Sell-to Country/Region Code" := SellToCustomer."Country/Region Code";
    end;
    if not SkipSellToContact then
    "Sell-to Contact" := SellToCustomer.Contact;
    "Gen. Bus. Posting Group" := SellToCustomer."Gen. Bus. Posting Group";
    "VAT Bus. Posting Group" := SellToCustomer."VAT Bus. Posting Group";
    "Tax Area Code" := SellToCustomer."Tax Area Code";
    "Tax Liable" := SellToCustomer."Tax Liable";
    "VAT Registration No." := SellToCustomer."VAT Registration No.";
    "VAT Country/Region Code" := SellToCustomer."Country/Region Code";
    "Shipping Advice" := SellToCustomer."Shipping Advice";
    "Responsibility Center" := UserSetupMgt.GetRespCenter(0, SellToCustomer."Responsibility Center");
  • Beginner Dynamics 365 Business Central Profile Picture
    95 on at

    Thank you for the reply.

    But I seem a bit confusing on what to do.

    Let me put it in a simple scenario.

    I have a table name : Participant

    I have a second table name: Application.

    In the participant table we record only personal details of the participant.

    In the second table, we record the application of a participant who has applied for a conference.

    So in the participant table, I have a field called ' Participant First Name' .

    And in the second table, we also have a field called 'first name' .

    So when a participant fill the participant first name field (participant table), they need to click on an action called 'apply for conference' which is in the participant table itself and then the second table will open (application table). That's where I want the first name to appear automatically.

    Example: in the first table I put the participant first name : John and when I click on the apply for conference action, the name John should automatically appear in the  second table of the first name field.

    Is there any simple way to do it?

    Thanks to let me know.

  • Verified answer
    Amit Baru Profile Picture
    3,037 on at

    Hi,

    I am explain you as per your requirement. 

    1. Create First Table with required Field and same Fields will visible on New Page.

    2. Create Second Table with required Field and same Fields will visible on New Page.

    3. Add Button on First page and write code on "OnAction" trigger.

    SecondTable.init

    SecondTable.Field1 := FirstTable.Field1;

    SecondTable.Field2 := FirstTable.Field2;

    SecondTable.Insert;

    For Learning regarding BC--> www.erpconsultors.com

    Regards

    Amit Sharma

    www.erpconsultors.com

  • Beginner Dynamics 365 Business Central Profile Picture
    95 on at

    Thank you Mr Amit.

    It works perfectly.

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,229

#2
Jainam M. Kothari Profile Picture

Jainam M. Kothari 1,867 Super User 2025 Season 2

#3
YUN ZHU Profile Picture

YUN ZHU 1,153 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans