Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more
Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more
Hi
IValidate is not called on delete, it's only called on save. If you want to have your code execute at delete from the UI you should attach it to IContentEvents. If you attach to DeletingContent you should be able to cancel the deletion, although I'm not sure if that is enough for your needs.
Regards
Per Gunsarfs
Might be moving content as well. Not sure if deleting trigger of moving to wastebasket. Didn't earlier at least..
For moving content, even to the wastebasket, MovingContent and MovedContent will be raised.
Note that there is no wastebasket concept for catalog content. (You can only delete them, which raises DeletingContent and DeletedContent)
Perhaps listening to those events will be enough.
/Q
@Quan
I was using EntryUpdating in CatalogEventListenerBase and I am trying to catch RowState => Deleted. But the CatalogEntryDto are null, is very strainge.
How do I use DeletingContent? DeletedContent?
there is not in CatalogEventListenerBase...
Its must fire when I Delete a Entry(Variation, product...) or Node
Hi
I will like to show in to user that are trying to delete a node with some entries in it.
I am using CatalogEventListnerBase. Is there any way to show the info?
I was trying to use IValidate, as belog, but did not fire...
public class CommerceNodeValidator : IValidate
{
readonly IContentRepositoryEpiAbstraction _contentRepositoryEpiAbstraction;
public CommerceNodeValidator(IContentRepositoryEpiAbstraction contentRepositoryEpiAbstraction)
{
_contentRepositoryEpiAbstraction = contentRepositoryEpiAbstraction;
}
public IEnumerable Validate(BaseCategoryNode instance)
{
var decendentEntries = _contentRepositoryEpiAbstraction.GetDescendents(instance.ContentLink.ToPageReference());
if (!decendentEntries.Any())
return Enumerable.Empty();
ValidationError[] validationError =
{
new ValidationError
{
ErrorMessage = "You cannot delete this node",
PropertyName = "CategoryNode",
Severity = ValidationErrorSeverity.Error,
ValidationType = ValidationErrorType.AttributeMatched
}
};
return validationError;
}
}