You need to do it using code behind the submit button. Below is what I did in jscript. Changing it to C+ should be easy.
function CTRL21_7::OnClick(eventObj)
{
var error_message = ""
try
{
XDocument.Submit();
}
catch (ex)
{
error_message = ex.message
if ( ex.message.indexOf("does not contain any new data") > 0 )
{
XDocument.UI.Alert("Record not updated. No data has been changed.");
}
else
if ( ex.message.indexOf("validation errors") > 0 )
{
XDocument.UI.Alert("Record not updated. There are validation errors. Errors are marked with either a red asterisk (required fields) or a red, dashed border (invalid values.");
}
else
if ( ex.message.indexOf("permission denied") > 0 )
{
XDocument.UI.Alert("Record not updated. You do not have permission to add, delete, or update records.");
}
else
if (ex.message != "")
{
bracket = ex.message.indexOf("[")
other_error = "Notify system administrator of critical error. " + ex.message.substr(bracket,500)
XDocument.UI.Alert (other_error);
}
else
if (ex.message == "")
{
XDocument.UI.Alert ("Draft saved successfully")
}
}
}