Hi,
When a Page is created, I would like to create an additional folder, which can be used to store images. These images can be read from the page and will be displayed in a jQuery image slider, if images are available. Each page can have it's own specific editor, so I would like it to be as automated as possible, and not having implicit functionalities like "create a folder with this name in order to display images".
I created the following code, as mentioned in http://devnet.kentico.com/docs/devguide/index.html?event_handlers_overview.htm:
[ImageFolderProviderModuleLoader]
public partial class CMSModuleLoader
{
	/// <summary>
	/// Module registration
	/// </summary>
	private class ImageFolderProviderModuleLoader : CMSLoaderAttribute
	{
		/// <summary>
		/// Initializes the module
		/// </summary>
		public override void Init()
		{
			DocumentEvents.Insert.After += Document_Insert_After;
		}
		private void Document_Insert_After(object sender, DocumentEventArgs e)
		{
			if (e.Node != null)
			{
				// First create a folder
				var folder = TreeNode.New("CMS.Folder", e.TreeProvider);
				folder.DocumentName = "Afbeeldingen";
				folder.DocumentCulture = "nl-NL";
				folder.Insert(e.Node.NodeID);
			}
		}
	}
}
However, when I try to add a new page, I get a "String or binary data would be truncated. The statement has been terminated." on folder.Insert(e.Node.NodeID) (or folder.Insert(e.Node) for that matter).
Is this the problem: from http://devnet.kentico.com/FAQs/API-and-Internals/Why-the-inserted-document-isn%E2%80%99t-accessible-in-the-.aspx: "The inserted node is not available at that moment because the transaction on the SQL server is still running at the moment when the event fires."?
However, I want to decouple my code from the UI, I don't want to resort into "hacking" in the existing pages, like the solution proposes: "You can try to ensure this in the following file which contains the code for creating new documents from the administration interface: ~\CMSDesk\Content\edit.aspx.cs" (which is in Kentico 6 in ~/CMSModules/Content/CMSDesk/New/new.aspx).
What is the proper way to resolve this? Is there an event after DocumentEvents.Insert.After when the document is available and the transaction is closed? Do I have to call DocumentEvents.Insert.FinishEvent();? Or am I missing something obvious?