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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Suggested Answer

Cancel Sales Order Error

(3) ShareShare
ReportReport
Posted on by 3,255
Hi All
WHen cancelling a sales order and save we get the below error. This is a non-customised system. If cancellation not allowed why the option is there to select. Business requirement is users from preventing delete sales orders and instead set the status to cancelled. 
Categories:
I have the same question (0)
  • Suggested answer
    Tom_Gioielli Profile Picture
    2,792 Super User 2025 Season 2 on at
    Can you replicate the error and download the log file to post? That will likely help us diagnose the issue a bit better.
     
    Actually, just something I noticed. It looks like you have the Status and status Reason fields up in the top ribbon. Are you simply updating the Status field to canceled as your update, or using some other method? I ask because your Status is Cancelled, but the Status Reason is still "new". Typically, you would click on the "Deactivate" button on the top of the order to change it to cancelled.
     
    If this answer helped, please consider marking as verified.
     
  • Samantha73 Profile Picture
    3,255 on at
    Since this is new environment it's strange this error comes up . log below
    Exception Message: This message can not be used to set the state of SalesOrder to Canceled.  In order to set state of SalesOrder to Canceled, use the CancelSalesOrderRequest Request message instead.
    ErrorCode: -2147220970
    HexErrorCode: 0x80040216
    ErrorDetails: 
        HttpStatusCode: 400
    TraceText: 
        [Microsoft.Dynamics.Sales.Plugins: Microsoft.Dynamics.Sales.Plugins.PreOperationSalesOrderUpdate]
        [fba59793-5468-e611-80e8-00155d2920d8: Update of Sales Order]
        Entered Microsoft.Dynamics.Sales.Plugins.PreOperationSalesOrderUpdate.Execute(), Correlation Id: 76a4a568-57e3-45ba-9543-acc96f578159, Initiating User: 90e5cfab-ef16-f011-998b-002248e3099d
        Exception: Microsoft.Dynamics.Solution.Common.CrmInvalidOperationException: This message can not be used to set the state of SalesOrder to Canceled.  In order to set state of SalesOrder to Canceled, use the CancelSalesOrderRequest Request message instead. (Fault Detail is equal to Exception details: 
        ErrorCode: 0x80040216
        Message: This message can not be used to set the state of SalesOrder to Canceled.  In order to set state of SalesOrder to Canceled, use the CancelSalesOrderRequest Request message instead.
        StackTrace: 
           at System.Environment.GetStackTrace(Exception e, Boolean needFileInfo)
           at System.Environment.get_StackTrace()
           at Microsoft.Dynamics.Solution.Common.CrmException.BuildOrganizationServiceFault(Exception innerException, Int32 errorCode, Int32 statusCode, String message)
           at Microsoft.Dynamics.Solution.Common.CrmException..ctor(String message, Exception innerException, Int32 errorCode, Int32 statusCode, Boolean isFlowControlException, Boolean enableTrace)
           at Microsoft.Dynamics.Solution.Common.CrmException..ctor(String message, Exception innerException, Int32 errorCode, Int32 statusCode, Boolean isFlowControlException)
           at Microsoft.Dynamics.Solution.Common.CrmException..ctor(String message, Exception innerException)
           at Microsoft.Dynamics.Solu...)., Correlation Id: 76a4a568-57e3-45ba-9543-acc96f578159, Initiating User: 90e5cfab-ef16-f011-998b-002248e3099d
        Exiting Microsoft.Dynamics.Sales.Plugins.PreOperationSalesOrderUpdate.Execute(), Correlation Id: 76a4a568-57e3-45ba-9543-acc96f578159, Initiating User: 90e5cfab-ef16-f011-998b-002248e3099d
    Activity Id: 7e3ef7d0-85e4-4022-91e1-199500a058b6
  • Suggested answer
    Anne Stanton, MCSE, MBA, CRM rMVP #7 Profile Picture
    65 on at
    You mentioned that this was a new environment, have you confirmed that the plugin steps are all enabled and that any business rules and/or workflows that are related are activated and have the right service account?
     
    Cheers Anne
  • Suggested answer
    Tom_Gioielli Profile Picture
    2,792 Super User 2025 Season 2 on at
    @Samantha73, can you verify how you are cancelling this order? Is it through a ribbon button, or by updating the state field directly in the header?
  • Suggested answer
    Daivat Vartak (v-9davar) Profile Picture
    7,835 Super User 2025 Season 2 on at
    Hello Samantha73,
     

    You've encountered a standard behavior in Dynamics 365 Sales designed to ensure data integrity and proper cancellation processes for Sales Orders. Even in a non-customized system, setting the status of a Sales Order to "Canceled" directly through the status dropdown and saving is not the intended method.

     

    The error message clearly states:

     

    This message can not be used to set the state of SalesOrder to Canceled. In order to set state of SalesOrder to Canceled, use the CancelSalesOrderRequest Request message instead.

     

    Why is this happening?

    The cancellation of a Sales Order in Dynamics 365 Sales involves more than just changing the status. It typically triggers several background processes, including:

    • Updating the status of related Sales Order Lines: These need to be set to "Canceled" as well.

    • Potentially releasing reserved inventory.

    • Preventing further modifications or fulfillment.

    • Logging cancellation details.

    •  

    The CancelSalesOrderRequest message is a specific API request designed to handle all these steps in a controlled and consistent manner. Simply changing the status field bypasses these crucial processes, which could lead to data inconsistencies and errors.

     

    Why is the "Canceled" option available in the Status dropdown?

    This can be a bit misleading. The "Status" field on the Sales Order entity often has a defined set of options, including "Canceled," to allow for various stages and outcomes of an order. However, for the specific action of canceling an order and triggering the associated business logic, the platform enforces the use of the CancelSalesOrderRequest.

     

    How to Properly Cancel a Sales Order (The Correct Method):

    Instead of directly changing the "Status" field and saving, you need to use the "Cancel Order" button available on the Sales Order form:

    1. Open the Sales Order record you want to cancel.

    2. Look for the command bar at the top of the form.

    3. Click on the "Cancel Order" button. (It might be under a "..." or "More Commands" menu if your screen resolution is smaller).

    4. A dialog box will appear asking for a "Cancellation Reason." Enter the reason for cancellation.

    5. Click "OK."

    6.  

    This action will use the CancelSalesOrderRequest message in the background, correctly setting the status to "Canceled" and triggering all the necessary related processes.

     

    Addressing Your Business Requirement:

    Your business requirement to prevent users from deleting Sales Orders and instead set the status to "Canceled" aligns perfectly with the intended functionality of the "Cancel Order" button. By using this button, you achieve the desired outcome of marking the order as canceled without physically deleting the record, preserving it for historical and reporting purposes.

     

    Why is this happening in a new environment?

    This behavior is by design in Dynamics 365 Sales and is not specific to customized environments or older versions. It's a core part of the platform's logic for handling Sales Order cancellations to maintain data integrity. The fact that it's a new environment doesn't bypass this fundamental process.

     

    In summary, to correctly cancel a Sales Order in Dynamics 365 Sales (including your new environment), you must use the "Cancel Order" button on the Sales Order form, which utilizes the CancelSalesOrderRequest message. Directly changing the "Status" field to "Canceled" and saving will result in the error you are seeing because it bypasses the required cancellation logic.

    Educate your users to use the "Cancel Order" button instead of manually changing the status. This will ensure that Sales Orders are canceled correctly and consistently within the system.

     
    If my answer was helpful, please click Like, and if it solved your problem, please mark it as verified to help other community members find more. If you have further questions, please feel free to contact me.
     
    My response was crafted with AI assistance and tailored to provide detailed and actionable guidance for your Microsoft Dynamics 365 query.
     
    Regards,
    Daivat Vartak
  • Samantha73 Profile Picture
    3,255 on at
    Thanks for all the replies
    Can we confirm that this is a standard behaviour? If so it makes no sense as you have an option from the front end to cancel but it doesnt work? Can anyone else cancel a sales order without this error?

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

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 > Customer experience | Sales, Customer Insights, CRM

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 70 Super User 2025 Season 2

#2
Gerardo Rentería García Profile Picture

Gerardo Rentería Ga... 33 Most Valuable Professional

#3
Daniyal Khaleel Profile Picture

Daniyal Khaleel 32 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans