In Sitecore 9 the event model has changed somewhat and events are now
queued within each DB (master, core, web etc).
This is partially correct. You could always queue remote events in your Sitecore database of choice. Sitecore 9 still has a concept of a preferred event queue database.
Two options for queueing a remote event
In your specific use case, Publishing is the Sitecore function that you are interested in. Therefore, I would create a Helix Module called Foundation.Publishing on the Foundation Level, and then add your Event Handler and associated patch configs there.
Generally speaking, customizations to Sitecore should be contained with the module ...
I would use item:created event handler, because this is only fired once, when the item is published. (Publish creates the item in web database).
It isn't fired multiple times, even if you create a new version from the item or republish the item instead of smart publish.
public void OnItemCreated(object sender, EventArgs args)
Item item = ((...
I would recommend creating an item:saved event handler to take the data and save the information you need.
Note: the item:saved event is different from the item:saving event
and I believe preferable in this case because the item:saving event
happens while the editor waits for the save command to complete.
Create a custom event handler
public class ...
You can achieve this by programmatically moving the bucketed item to the root of the bucket with the BucketManager. Doing this will force it to reevaluate the bucket rules and reorganize it:
In our solutions, we typically create an item:saved event handler to do this automatically:
Can't say I've had to do this, but firing up my friend ILSpy, I've got a few ideas for you:
You can open Sitecore.Kernel and find IEventQueue and "analyze" the QueueEvent() method to find places it's used in real code.
That lets me find this code:
private Handle QueuePublish(DistributedPublishOptions options, Language clientLanguage)
Handle handle ...
Any event handler has to follow a few conventions:
The class must have a method that accepts two parameters and return void:
object - represents the object that holds a collection of the various event listeners
EventArgs - holds the parameters being passed to the event handler
For your case, if you added the following event handlers for the ...
What are Events in Sitecore?
The best description of what Events are would probably be the one provided by Sitecore:
Events track visitor activity on a website. Tracking events helps build up a more complete picture of a visitor’s behavior as they navigate your website. You should assign engagement value points to all events to reflect their relative ...
I have not practically use the Events as much but from the definition and research, I am writing this answer hopefully it will clear your doubts.
An event is anything significant that occurs within the context of an interaction, such as viewing a web page or making a purchase in a physical store.
When an event is triggered, an event definition ID is ...
You can create "Code Beside" pages in ASPX/C# that embeds a small amount of code. We sometimes need to see which Solr cores are connected where (when troubleshooting) as we version our Solr with each new release.
To do that we use Azure's "App Service Editor" to open an in-browser VS Code instance pointed at the running production site.
You can get this information using reflection mechanism and internal item.GetChanges(true) method:
Get ItemChanges by executing GetChanges(true) with reflection
Get FieldChanges from ItemChanges.
Get underlying _field field from every FieldChange with reflection again
Check if any of the fields has ResetBlank flag set to true.
public class ...
The answer to my original question could have worked as Mark suggested, by looking at Context.Site.Name during the onSaving event, but then I tried to go with the best practice and use UISaved pipeline, as it triggers only when the Sitecore user "Saves" from within the Sitecore Content editor, so that worked perfectly for my case.
I was trying to change my ...