Search code examples
dynamics-crm

How to prevent user from cancelling a salesorder using js?


My mission is: after the user clicks on cancel order button, I need to check some data and if the data is true, I need to prevent from the button functionality to run and alert the user, where can I insert my code?

Mscrm.Form.salesorder.CancelOrder is a vanilla button and seems close to add or edit, how can I do that?


Solution

    1. Either you can do a pre-update plugin, check the business logic and throw InvalidPluginExecutionException if it is satisfied
    2. You can use custom action by customizing the OOB cancel button or by hiding it and introducing a custom cancel button to invoke custom action or script to alert