Hi friends, small tip, I got chancel to add validation in Cancel functionality of D365 Finance and operations.Interestingly the menu button called the class. So I have to write the pre event handler for main method.
Following is the [[Code Snippet]]
public static void SalesCancelOrder_Pre_main(XppPrePostArgs _args)
{
Args args =_args.getArg("args");
SalesTable salesTable = args.record();
CustmTable _Response;
select * from _Response where _Response.PrimaryKey == salesTable.SalesId && _Response.TransType == CustmTransType::SalesOrder;
if (_Response.RecId !=0)
{
// validateEventArgs.parmValidateResult(false);
Error("This sales order is integrationed with wms, Cancellation is not recommended, use the cancellation dailog for Cancel in wms.");
if (Box::yesNo("Sales order is integrated with WMS, Do you really want to cancel it.", DialogButton::No) == DialogButton::No)
{
throw Exception::Error;
}
}
}