Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tridion 2011 workflow minor version increments using event handler custom code

We have Tridion 2011 and page process workflow as well. We have event handler on page pre save. When the user saves a page an event handler is called to modify the page metadata and a workflow is initiated. So the minor versioning of the page goes to 0.3 on every editor save click. So basically: 0.1 - Tridion version for page Save 0.2 - Event handler code executed for saving page metadata and because of Save() call this code gets called again to lead to the next minor version 0.3 - Same event handler code gets executed.

What I'm trying to achieve is to keep the minor version to 0.1 on every user Save click.

I've tried Pre Save Post Save, Pre Check in and Post Check in and changed the order of execution i.e. last param of the event system subscribe call but nothing helped. So pl. help :)

like image 901
Rohan Gadiya Avatar asked Dec 10 '12 18:12

Rohan Gadiya


1 Answers

Why are you calling Save() in your event? If you make your changes BEFORE the page is saved, then it should store everything in one go, without you ever calling Save.

public PageEvent()
{
    EventSystem.Subscribe<Page, SaveEventArgs>(ChangePageTitle, EventPhases.Initiated);
}
private void ChangePageTitle(Page page, SaveEventArgs args, EventPhases phases)
{
    page.Title = "Nuno was here " + page.Title;
}

This will change the page title, and as you see I don't call Save, since the editor did that already.

like image 132
Nuno Linhares Avatar answered Oct 15 '22 06:10

Nuno Linhares