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

Notifications

Announcements

Community site session details

Community site session details

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

Extension Question

(0) ShareShare
ReportReport
Posted on by 45

Hi All,

I am trying to create a relationship between Sales Quotes and Simulated Production Orders.

I wrote a very simple extension which adds a new field to the Sim Prod. Order to store the quotation number reference and also created a new action on the Sales Quote page for the creation of a new Simulated Production Order.

Using the following it successfully creates a new Sim Prod Order

action("CreateNew")
            {
                CaptionML = ENU = '+ New Sim Order';
                Image = Production;
                ApplicationArea = All;
                RunObject = page "Simulated Production Order";
                RunPageMode = Create;               
            }
My question is... How do I get send the Quotation number to the Sim Prod Order at time of asking it to create a new one?
I have the same question (0)
  • Azzure-IT-CSwann Profile Picture
    45 on at

    Just in case anyone else has a similar request. This is how I solved my question, with the help of Josh.

    Create a codeunit to handle the creation of a new record:

    ...

    codeunit 50100 "NewSPO"

    {

       procedure Foo(rec: Record "Sales Header")

       var

           Prod: Record "Production Order";

       begin

           Prod.Init();

           Prod."Quote No." := rec."No.";

           prod.Status := "Production Order Status"::Simulated;

           Prod.Insert(true);

           Page.Run(Page::"Simulated Production Order", Prod);

       end;

    }

    On the page, create an action that invokes the codeunit and passes the Record with it:

    ...

    action("CreateNewSPO")

               {

                   CaptionML = ENU = '+ New Sim Order';

                   Image = Production;

                   ApplicationArea = All;

                   trigger OnAction()

                   var

                       cu: Codeunit "NewSPO";

                   begin

                       cu.Foo(Rec);

                   end;

               }

  • Azzure-IT-CSwann Profile Picture
    45 on at

    Hi Josh,

    Thank you so much for taking the time to help me. Much appreciated.

    My programming experience is in C# for winforms, xamarin mobile and Unity and there is so little training resource regarding the correct syntax for AL and code units etc. There are a lot of snippets but I cant find anything to help me understand this better. But that's another problem... Thank you again for helping me here.

  • Suggested answer
    JAngle Profile Picture
    137 on at

    You will need to pass a parameter to a function. So from the quote you pass the current record as a variable to a function which creates the simulated production order. It will require code based actions instead of the property based version you have. This pattern exists across the system. Take a look at this simple one:

    action("Archive Document")

                   {

                       ApplicationArea = Suite;

                       Caption = 'Archi&ve Document';

                       Image = Archive;

                       trigger OnAction()

                       begin

                           ArchiveManagement.ArchiveSalesDocument(Rec);

    CurrPage.Update(false);

                       end;

                   }

    You could do this with a report or codeunit. The report version would be like where you print a sales quote and you pass (in code) the quote no.

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

News and Announcements

Season of Giving Solutions is Here!

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 1,457

#2
Khushbu Rajvi. Profile Picture

Khushbu Rajvi. 742 Super User 2025 Season 2

#3
YUN ZHU Profile Picture

YUN ZHU 669 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans
Liquid error: parsing "/globalsearch/?q=refine+this+slack+message%3A%0A%0A%40nasuraba+Thanks+for+setting+up+the+call+today%3A++If+there+is+any+feedback+from+the+team+after+we+dropped+off%2C+you+may+add+that+here.+%0ACan+we+plan+on+the+next+steps%3A+One+of+the+actions+was+to+create+a+value+proposition+slide.++" - Nested quantifier +.