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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

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

How to transfer data from one table to another?

(0) ShareShare
ReportReport
Posted on by

I am having a custom action on 2 different pages. 'event card' and 'event template', and on both actions the same page are getting opened (Eventcat.print) and on the template page, the template no and type will come automatically.  if I add the same template no in the event card. I am trying to copy all the records ie the 'type' and the 'template no.' into the event card., and now the template number and type are coming, but I have a 3-column code. in 'Event cat.print' Page. which is a lookup to another table(category print) and the user manually selects the code, but now I need to copy the 'code' to the event card .based on the event template number.

action("Event Cat. Print")
            {
                Caption = 'Event Cat. Print';
                ApplicationArea = all;
                Image = Accounts;
                trigger OnAction()
                var
                    Eventcategoryprint3: Record "Event Cat. Print" temporary;
                    Categoryprint: Record "Category Print";
                begin
                    Eventcategoryprint3.Reset();
                    Eventcategoryprint3.SetRange(No, REC."No.");
                    if not Eventcategoryprint3.FindFirst() then begin
                        Message('no');
                        Eventcategoryprint3.Init();
                        Eventcategoryprint3.Type := Eventcategoryprint3.Type::"Event";
                        Eventcategoryprint3.No := rec."No.";
                        Eventcategoryprint3.code := Eventcategoryprint3.code;
                        Eventcategoryprint3.Insert();
                    end;
                    if rec."Template No." <> '' then begin
                        Message('yes');
                        Eventcategoryprint3.Reset();
                        Eventcategoryprint3.SetRange(No, Rec."Template No.");
                        if not Eventcategoryprint3.FindFirst() then begin
                            Categoryprint.Reset();
                            Categoryprint.SetRange(code, Eventcategoryprint3.No);
                            IF not Categoryprint.FindFirst() THEN begin
                                Message('categoryprint%1', Categoryprint.code);
                                Eventcategoryprint3.Init();
                                Eventcategoryprint3.Type := Eventcategoryprint3.Type::Template;
                                Eventcategoryprint3.No := rec."Template No.";
                                Eventcategoryprint3.code := Categoryprint.code;
                                Eventcategoryprint3.Insert();
                            end;
                        end;
                    end;
                    Eventcategoryprint3.Reset();
                    page.Run(50001, Eventcategoryprint3);//
                end;

I am looking for a result like  these  but in my case 'code' [ A, B is blank

pastedimage1673873276898v1.png

  • Suggested answer
    Nitin Verma Profile Picture
    21,812 Moderator on at

    Please check the yellow one in your code.

    action("Event Cat. Print")
                {
                    Caption = 'Event Cat. Print';
                    ApplicationArea = all;
                    Image = Accounts;
                    trigger OnAction()
                    var
                        Eventcategoryprint3: Record "Event Cat. Print" temporary;
                        Categoryprint: Record "Category Print";
                    begin
                        Eventcategoryprint3.Reset();
                        Eventcategoryprint3.SetRange(No, REC."No.");
                        if not Eventcategoryprint3.FindFirst() then begin
                            Message('no');
                            Eventcategoryprint3.Init();
                            Eventcategoryprint3.Type := Eventcategoryprint3.Type::"Event";
                            Eventcategoryprint3.No := rec."No.";
                            Eventcategoryprint3.code := Rec.code; //See this if this ok or Generate new one
                            Eventcategoryprint3.Insert();
                        end;
                        if rec."Template No." <> '' then begin
                            Message('yes');
                            Eventcategoryprint3.Reset();
                            Eventcategoryprint3.SetRange(No, Rec."Template No.");
                            if not Eventcategoryprint3.FindFirst() then begin
                                Categoryprint.Reset();
                                Categoryprint.SetRange(code, Eventcategoryprint3.No);
                                IF not Categoryprint.FindFirst() THEN begin
                                    Message('categoryprint%1', Categoryprint.code);
                                    Eventcategoryprint3.Init();
                                    Eventcategoryprint3.Type := Eventcategoryprint3.Type::Template;
                                    Eventcategoryprint3.No := rec."Template No.";
                                    Eventcategoryprint3.code := Rec.code; //See this if this ok or Generate new one
                                    Eventcategoryprint3.Insert();
                                end;
                            end;
                        end;
                        Eventcategoryprint3.Reset();
                        page.Run(50001, Eventcategoryprint3);//
                    end;
  • Community Member Profile Picture
    on at

    Thanks for the reply Nitin Verma here the isssue is there is no record in the event header with code, so we cannot use like you suggested---> Eventcategoryprint3.code := Rec.code; //See this if this ok or Generate new one

  • Suggested answer
    Nitin Verma Profile Picture
    21,812 Moderator on at

    Then How you want to generate the Code here?

    Thanks.

  • Community Member Profile Picture
    on at

    here the code will be the Eventcategoryprint3.code := Categoryprint.code; ,this is the possible one but no luck it doesnot the works,

    the code is coming from different table --> categoryprint.

    thats why iam trying to setrange with the template no and code , but  still its doesnot work

    pastedimage1673879600270v1.png

  • Suggested answer
    Nitin Verma Profile Picture
    21,812 Moderator on at

    Yes it will never work, because there is nothing with Categoryprint.findfirst, so it will not assign any value. You need to either generate a new code. or modify your code.

    Thanks.

  • Community Member Profile Picture
    on at

    yes, that is what happening now ....

    in both the pages same table used that is what the issue otherwise it will be easy to assign the value. On the same action i can make the modification or on the page level on afterget record will be more efficient?

    thanks for your help ,let me try to modify the code, Thanks you.

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the August Top 10 Community Leaders

These are the community rock stars!

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 796 Super User 2026 Season 2

#2
YUN ZHU Profile Picture

YUN ZHU 481 Super User 2026 Season 2

#3
AndrewThomas81 Profile Picture

AndrewThomas81 377 Super User 2026 Season 2

Last 30 days Overall leaderboard

Featured topics

Microsoft Training Manuals

Product updates

Dynamics 365 release plans