Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Fast Forward item in SDL Tridion Events to ease Workflow and Adding Component to Page
[TcmExtension("Event System")]
public class EventSystem : TcmExtension
{
public EventSystem()
{
Subscribe();
}
public void Subscribe()
{
//Workflow Related Events
EventSystem.Subscribe<Component, SaveEventArgs>(ComponentSavedWorkflowEvent, EventPhases.Processed);
}
private void ComponentSavedWorkflowEvent(Component subject, SaveEventArgs e, EventPhases phase)
{
if(subject.IsNew)
{
if(subject.GetProcessDefinition() != null)
{
//Get current instance & force finish version 0.x
var processInstance = new ProcessInstance(subject.CurrentActivity.Process.Id, subject.Session);
processInstance.ForceFinish(new ApprovalStatus(subject.Session));
//Trigger save to send version 1.x into workflow
var newSubject = new Component(subject.Id.GetVersionlessUri(), subject.Session);
newSubject.CheckOut();
newSubject.Save(true);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment