Convert Sales Quote to Sales Order and Replace Default No. Series.

Scenario:

You process multiple types of quotes using a related No. Series. However, when you convert your quote to a Sale Order, the Sales Order will be created based on the default No. Series of Sales Orders according to your “Sales and Receivable Setup”.

Problem:

How to you keep the Sales Order in a separate No. Series based in the type of Quote that you originally created?

Solution:

Here is a little trick with minimal coding that will help you achieve your goal.  In the example we’ll use “Type 2 Quote” and “Type 2 Sales Order” as the alternates.  This represents a second type of Quote and its desired related Sales Orders.

Steps:

  1. Insert a new No Series.  This will be the No. Series of the “Type 2 Sales Orders” you would like to use for “Type 2 Quotes”.
  2. Set the relationship to the Default No. Series that is currently being uses as Sales Orders.
  3. Add a new field to the No. Series (table 308) and (page 456) called “Convert to No. Series.” as Code 10 and set the TableRelation to the “No. Series” table.
  4. On the “Quote Type 2” No. Series record, populate “Convert To Nos.” field with the No. Series of ”Sales Order Type 2”.
  5. In the “OnRun” trigger of CU86 “Sales-Quote to Order” insert the follow code for “assign Order No. Series based on originating quote No. Series”:


OnRun(VAR Rec : Record "Sales Header")
TESTFIELD("Document Type","Document Type"::Quote);
Cust.GET("Sell-to Customer No.");
Cust.CheckBlockedCustOnDocs(Cust,"Document Type"::Order,TRUE,FALSE);
CALCFIELDS("Amount Including VAT");
SalesOrderHeader := Rec;
IF GUIALLOWED AND NOT HideValidationDialog THEN
CustCheckCreditLimit.SalesHeaderCheck(SalesOrderHeader);
SalesOrderHeader."Document Type" := SalesOrderHeader."Document Type"::Order;

CheckAvailability(Rec);
CheckInProgressOpportunities(Rec);
// xxx.xx.xx --> assign Order No. Series based on originating quote No. Series
IF "No. Series" '' THEN BEGIN
NoSeries.GET("No. Series");
IF NoSeries."Convert To Nos." '' THEN
SalesOrderHeader. "No. Series" := NoSeries."Convert To Nos.";
END;
// xxx.xx.xxx

Now when the alternate No Series is used to create “Quote Type 2” Quotes, the converted Sales Orders will use the new “Sales Order Type 2” No. Series.

You can also use this same logic in other areas. Just don’t forget to set the Relationship of the No. Series or you will always be populating the new record with the default No. Series when you intended on it being overridden.

Leave a Reply