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...
Suggested Answer

Cancel Sales order with Special Order

(0) ShareShare
ReportReport
Posted on by 742

Hello everyone,

I'm working with a customer who is generating purchase orders through requisition worksheet, based on sales orders with special order. I have a situation: It's a sales order with 500 pieces of a product and I have shipped 400 pieces. I have a generated purchase order with 500 pieces (that fufills the sales order) and I only have received 400 pieces.

There are 100 pieces that have been cancelled by the customer. So I need to cancel that quantity for both, purchase and sales order. 

In order to cancel the purchase order, I can reopen the order, change the original quantity and then run the task to delete invoiced purchase orders. But, I have this error when I try to do the same with the sales order:

pastedimage1631839736883v1.png

If you coud help me, I would really appreciate it. 

Thank you!
Valeria.

I have the same question (0)
  • Suggested answer
    JAngle Profile Picture
    135 on at

    Others might suggest a more elegant way of resolving this. I've found in this circumstance you no longer need the link and you can progress to the next stage with either document without it. A few ways of doing it code wise but here is one avenue I've used in the past.

    pageextension 50100 "SO Subform Ext." extends "Sales Order Subform"
    {
        actions
        {
            addafter("Speci&al Order")
            {
                action(Cancel)
                {
                    ApplicationArea = All;
                    Caption = 'Cancel Special Order Lines';
                    trigger OnAction()
                    var
                        SalesLine: Record "Sales Line";
                        PurchLine: Record "Purchase Line";
                    begin
                    IF NOT CONFIRM('Would you like to clear the Special Order fields?', TRUE)
                            THEN EXIT ELSE
                        SalesLine.RESET;
                        SalesLine.SETRANGE("Document Type", Rec."Document Type");
                        SalesLine.SETRANGE("Document No.", Rec."Document No.");
                        IF SalesLine.FIND('-') THEN
                            REPEAT
                                IF PurchLine.GET(Rec."Document Type", SalesLine."Special Order Purchase No.", SalesLine."Special Order Purch. Line No.") THEN BEGIN
                                    CLEAR(PurchLine."Special Order Sales Line No.");
                                    CLEAR(PurchLine."Special Order Sales No.");
                                    CLEAR(PurchLine."Special Order");
                                    CLEAR(PurchLine."Purchasing Code");
                                    PurchLine.MODIFY(TRUE);
                                END;
                                CLEAR(SalesLine."Special Order Purch. Line No.");
                                CLEAR(SalesLine."Special Order Purchase No.");
                                CLEAR(SalesLine."Special Order");
                                CLEAR(SalesLine."Purchasing Code");
                                SalesLine.MODIFY(TRUE);
                            UNTIL SalesLine.NEXT = 0;
                    end;
                }
            }
        }
    }

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,719

#2
Khushbu Rajvi. Profile Picture

Khushbu Rajvi. 812 Super User 2025 Season 2

#3
YUN ZHU Profile Picture

YUN ZHU 728 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans