In Tridion 2011 SP1 I’m trying to implement an event that will publish items automatically whenever the editor presses Save & Close (but not Save).
Under normal conditions this could be handled in a CheckIn event, but because this item will probably be in workflow, there is no CheckIn event (yet).
In COM Events we had a flag (doneEditing) to tell us if the editor had pressed save & close vs Save. I don’t seem to be able to find a similar option in TOM.NET Events.
For reference – here’s the code so far:
[TcmExtension("Publish to Wip Events")]
public class PublishToWip : TcmExtension
{
public PublishToWip()
{
EventSystem.SubscribeAsync<VersionedItem, SaveEventArgs>(PublishItemToWip, EventPhases.TransactionCommitted);
}
private void PublishItemToWip(VersionedItem item, SaveEventArgs args, EventPhases phases)
{
// Magic goes here
}
}
I’ve looked at the options for SaveEventArgs, but haven’t found anything that would provide me this information. Any tips?
Alright, with some help from the CM team I got the right answer to this.
Use the CheckInEvent instead of save. Even if the item is in workflow it will still invoke this event when you click Save & Close (and only if you click Save & Close, not when you click Save).
Something like this will get me going: