Last week I saw an interesting question on the D365 forum, the user wants to retain the sales quote after it has been converted to a sales order.
As you might know, you create a sales quote to record your offer to a customer or a prospect to sell certain products on certain delivery and payment terms.
When the customer accepts the quote, you convert the sales quote to a sales invoice or a sales order in which you process the sale.
After converting to an order, the sales quote will be automatically deleted.
Of course, the best practice should be to enable the Archive Quotes feature in Sales & Receivables Setup.
After the sales quote is deleted, it can be automatically archived into the Sales Quote Archives.
PS: Although you can find the Restore function in the Sales Quote Archive, if your Sales Quote has been completely deleted, this function is not available.
Transfer the contents of this archived version to the original document. This is only possible if the original is not posted or deleted.
I find this a bit inconvenient.
Unposted Quote 1006 does not exist anymore. It is not possible to restore the Quote.
So if the user cannot accept the Archive Quotes solution, what should be done?
We’ve discussed how to keep Orders after completely invoiced before, I think that’s possible as well. So I briefly investigated the standard code (Base App).
Then found an event available.
OnBeforeDeleteSalesQuote(Rec, SalesOrderHeader, IsHandled, SalesQuoteLine) in codeunit 86 “Sales-Quote to Order”
Let me do a simple test. (If you are in official development, it is best to add a setting to control whether this customization is enabled)
codeunit 50111 MyCodeunit
[EventSubscriber(ObjectType::Codeunit, Codeunit::"Sales-Quote to Order", 'OnBeforeDeleteSalesQuote', '', false, false)]
local procedure OnBeforeDeleteSalesQuote(var IsHandled: Boolean);
IsHandled := true;
Isn’t it very convenient? We can use Sale Quote as a template to create Sales Order infinitely. . . . This looks a bit simpler than the Copy Document and Recurring orders features.🧐
Hope this will help.
Thanks for reading.