In Umbraco V7 how to show custom error validation message on back office save or publish to user
I have tried following but it shows 'Publishing was cancelled by a 3rd party plugin' not actual error message
void ContentService_Saving(IContentService sender, SaveEventArgs<IContent> e)
{
e.Cancel = true;
ShowErrorBubble("Error saving item", "Error:duplicate records exists");
}
private static void ShowErrorBubble(string title, string exception)
{
try
{
umbraco.BasePages.UmbracoEnsuredPage.Current.ClientTools.ShowSpeechBubble(umbraco.BasePages.UmbracoEnsuredPage.speechBubbleIcon.error, title, exception);
}
catch (Exception ex)
{
//do nothing at the moment, forums suggest we cannot send an error message
}
}
That's an old snippet you're using. It never worked properly that way anyhow. Try this code instead:
void ContentService_Saving(IContentService sender, SaveEventArgs e)
{
ShowErrorBubble(e, "Error saving item", "Error:duplicate records exists");
}
private static void ShowErrorBubble(SaveEventArgs e, string title, string text)
{
try
{
e.Messages.Add(new Umbraco.Core.Events.EventMessage(title, text, Umbraco.Core.Events.EventMessageType.Warning));
e.Cancel = true;
}
catch (Exception ex)
{
//do nothing at the moment, forums suggest we cannot send an error message
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With