Multiple K2 SharePoint Event Processes

K2 Add comments

K2identity_4C_RGB_gif

Recently I ran into an interesting problem while developing K2 SharePoint Event Processes. My project was made up of multiple processes that were kicked-off when a new item was added to a SharePoint list. Initially the first process was deployed without a problem, however as I tried to deploy additional processes to the server I received the following error:

Task Error: System.Web.Services.Protocols.SoapException: Server was unable to process request. —> Unexpected end of file has occurred. The following elements are not closed.

Deployment Error Message

When looking in the event log I found the following entry:

Event Log Error

After quite a bit of research and reaching out the K2 Insiders community, I managed to resolve it with support from the K2 support team.

My project structure was broken down by project name, with folders separating processes by function and then the processes below that. When deploying a K2 SharePoint Events process that is triggered by the ‘Item Added’ event, two rows are created in the EventReceivers table of the SharePoint web application content database (one with a name of MyProcessName_ItemAdding and one with the name of MyProcessName_ItemAdded). These two rows are created for each SharePoint list that has one or more K2 Events process associated with it.

The ‘Data’ column in this table contains an XML string that includes each K2 SharePoint Events process name.  For example, the ‘Data’ column for a SharePoint list that has two K2 Events Processes associated with it might look something like this: <Data><Process>MyProjectName\MyFolderName\MyProcessName</Process><Process>MyProjectName\MyFolderName2\MyProcessName2</Process></Data>

It turns out that the ‘Data’ column in the EventReceivers table has a data type of nvarchar(256).  When deploying multiple Events processes associated with the same SharePoint list, if the total length of this xml string eventually exceeds 256 characters, the deployment error will occur.

Navigating to the ‘K2 Manage Events’ page in SharePoint, or trying to redeploy will cause the following error as the data in the ‘Data’ column of the EventReceivers table has been truncated:

Unexpected end of file has occurred.  The following elements are not closed: Process, Data. Line 1, position 257.

SharePoint Manage K2 Events Error

To access the ‘K2 Manage Events’ page again, I needed to delete the two rows from the EventReceivers table.

One possible solution was to change the project structure and use shorter names, ensuring that I didn’t exceed 256 characters (including the K2 XML tags the processes are wrapped in). However, this would only be a workaround though as anyone adding multiple processes to be triggered off a list may run into the problem. The field length in the table cannot be changed as it is a SharePoint database table and the effects of altering it is unknown (never mind the warranty/support issues that would raise).

Another solution is to limit the number of processes that are attached to the list. Unfortunately, I was unable to do that as it was a dumping area for documents that are scanned.

The solution I ended up using was to create a Dispatcher process to handle all interactions with the list and to call the relevant processes as required. It is still not ideal though, as every time a new process has to be fired off when there is an interaction with the list, the Dispatcher process needs to be updated.

K2 has opened a ticket regarding this issue and hopefully a more elegant solution is found. One thing to note is that this only affects K2 SharePoint Event Processes and NOT SharePoint Workflow Integration Processes.

, , ,

View blog reactions

Bookmark and Share Bookmark and Share

Leave a Reply

WP Theme & Icons by N.Design Studio
Entries RSS Comments RSS Log in