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

Announcements

News and Announcements icon
Community site session details

Community site session details

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

Automatically adding an item to the sales order

(0) ShareShare
ReportReport
Posted on by

Hi,

I have a problem related to Sales orders. In our business we very often sell certain products (let's call it item A) which requires to add a non-inventory item (Item B) to the sales order. For example:

Sales order:

1. We add Item A 100 pcs X price

2. We add Item B 100 pcs Y price (mandatory addition, if Item A is added to a sales order)

As we always need to add the Item B, it would make sense to automate adding it. However, we are quite new to the Business Central world so I don't really know where to start figuring this out. Logically the easiest solution would be some sort of automation that basically would automatically add the item B on the sales order after inputting Item A to a sales order. However, I don't have any idea if this is possible?

There must be some way to handle this, as I feel this is fairly common issue?

All help or comments are appreciated!

I have the same question (0)
  • Verified answer
    Akshay_Panchal Profile Picture
    402 on at

    Hi,

    You have to right code after Insert A item code on line.After this insertion of A line you can right code for the insertion of b line.

    So you have to call eventsubscriber as below

     [EventSubscriber(ObjectType::Table37'OnAfterInsertEvent''', true, true)]
        local procedure OnAfterInsertEventSalesLine(var Rec: Record "Sales Line")
        var
            SalesLine: Record "Sales Line";
            LastSalesLine: Record "Sales Line";
            LineNo: Integer;
        begin
            if Rec."No." = '1000' then begin
                LineNo := 0;

                LastSalesLine.Reset();
                LastSalesLine.SetRange("Document Type", Rec."Document Type");
                LastSalesLine.SetRange("Document No.", Rec."Document No.");
                if LastSalesLine.FindLast() then
                    LineNo := LastSalesLine."Line No." + 10000
                else
                    LineNo := 10000;

                SalesLine.Init();
                SalesLine."Document No." := Rec."Document No.";
                SalesLine."Document Type" := Rec."Document Type";
                SalesLine."Line No." := LineNo;
                SalesLine.Insert(true);
                SalesLine.Validate(Type, SalesLine.Type::Item);
                SalesLine.Validate("No.", '1100');
                SalesLine.Modify();

            end;
        end;
    If you enter the 1000 item code system will auto add the 1100 item line on order according to above code.
    Also you can set dynamic with adding field Sub Item No. on Item Table so system will auto create line base on the field.
    see above code output as below
    pastedimage1635161397905v1.png

    Verify, If this answer helpful for you

  • Verified answer
    Ben Baxter Profile Picture
    7,107 Super User 2026 Season 1 on at

    While the above customization would work in the scenario where you only need to add 1 additional Item, it will become more clunky if you need to add 3 additional products when you add the first.

    You could look at using the standard Assembly Management functionality within BC.  This would allow you to explode the components onto the lines for visibility.

    Assembly Mgmt. would also allow you to pre-pack the bundles so you don't forget to add them at time of shipment.

  • Community Member Profile Picture
    on at

    For any other folks battling this issue. Akshay's code is a very prominent solution, especially if the need is just to add one additional item to the order. If you get the code working, this is really helpful as it's fully automated.

    Ben's solution through Assembly Management functionality is the way to go when there are multiple line's to be added for a certain item. However, this requires a couple of clicks from mouse so it's not the most quickest solution. However, those clicks are worth it, especially if sold item consists of multiple different/complex set of items with different quantities. For example, if salesperson is selling a product XYZ, he/she doesn't have to remember the composition of XYZ, just add that product through the Assembly Management and then break the item down on the Sales order.

    Example:

    1. Salesperson put's 1 XYZ item on the order.

    2. Salesperson navigates to Row -> Functions -> Explode BOM

    3. This item turns into a comment line and below that you can find the items with correct quantities set up through Assembly management.

    Comment: Item XYZ

    Item X 3 pcs

    Item Y 6 pcs

    Item Z 9 pcs

    This way salesperson doesn't need to remember how many X, Y or Z is in the Item XYZ. Salesperson is only required to set how many Item XYZ customer needs.

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 Launch!

Jump in, show your community spirit, and win prizes!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,497 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 1,778 Super User 2026 Season 1

#3
AndrewThomas81 Profile Picture

AndrewThomas81 1,507

Last 30 days Overall leaderboard

Featured topics

Microsoft Training Manuals

Product updates

Dynamics 365 release plans