I have a requirement like when user clicks on the Publish Item button, I wanted to execute some custom code where I will run some validations against the current item and if it's all good, then the item will be published otherwise an alert will be displayed and the publish pipeline should be disabled.
So for this I have created custom processor under publishItem pipeline and it all works good but when I am showing the alert it's giving me null reference exception.
Sitecore.Context.ClientPage.ClientResponse.Alert(message);
I am not sure what wrong I am doing here and is there any other way to achieve this ...Please suggest
Below is the sample code which I wrote
The below class is inherited from PublishItemProcessor.
public override void Process(PublishItemContext context)
{
Assert.ArgumentNotNull(context, "context");
// code goes here
if (condition)
{
string message = "Required fields are missing";
context.AbortPipeline();
Sitecore.Context.ClientPage.ClientResponse.Alert(message);
}
}
<publishItem>
<processor type="Namespace.CheckRequiredChildItems, Namespace" />
</publishItem>
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…