Only trigger publish events when caused by an editor


My goal is to trigger publish events only when a page is published by an editor or a certain condition is met.

We have some jobs that parse, populate and republishes content on a regular basis but I would like to not trigger publish events when triggered by jobs. 

Any ideas?

Jul 12, 2018 11:25

I solved it for now by always using SaveAction.ForceCurrentVersion when saving from job and do a check in the event if SaveContentEventArgs.ForceCurrentVersion is true.

Edited, Jul 12, 2018 12:56

Hi Toft,

Try SaveAction.Patch

Jul 13, 2018 7:18

We usually set up a "service account" user to use for automated tasks, such as scheduled jobs, etc.

var humanUser = PrincipalInfo.CurrentPrincipal;

var userImpersonation = ServiceLocator.Current.GetInstance<IUserImpersonation>();


// Do work as 'SomeServiceAccount'

PrincipalInfo.CurrentPrincipal = humanUser;

This way we get more relevant version history (as we can see what has been done by an editor and what has been done by an integration, scheduled job, or such) and at the same time we can use current user info to determine whether specific validation should take place.

It also avoids scheduled jobs being run as anonymous users, forcing developers to add SaveAction.NoAccess when working with IContentRepository methods.

I realize this doesn't exactly answer your original question, but suppressing/avoiding publishing events can have adverse (unintentional) side-effects. :)

Edited, Jul 13, 2018 9:01

Yes, I found that one soon after posting, very useful.

Jul 13, 2018 10:06

This looks exactly like what we'll set up when we find SaveAction.Patch isn't enough. Thank you.

Jul 13, 2018 10:08
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.