I recently encountered a situation with a customer where they used InfoPath processes in their environment and I noted that they had a large growth in their K2ServerLog database even though the number of process instances was relatively small.
Now this was puzzling until I did the math here.
e.g. 2000 form instances. Each form has on average roughly 200KB attachments per form. The process had a couple of approval stages and has about 2-3 slots per stage. Let's assume a figure of 7 slots here. Including the process instance data, this would result in 8 copies of the form data.
Also note the following:
- The InfoPath client event makes a copy of the InfoPath document per slot
- InfoPath file attachments need to be base64 encoded. This roughly multiplies the attachment size by 1.37 times.
This leads to 2000 X 200KB X 1.37 X 8 = 4.18GB of data.
Now this is a hefty size to manage for just 2000 instances (and it just multiplies as the process gets more complex and the number of instances grow over time).
If you are interested in finding out the table usage in your own K2 environment, you can run this following useful command on your K2ServerLog database.
EXEC sp_MSforeachtable @command1=”EXEC sp_spaceused ‘?’”
So from an InfoPath standpoint, putting in file attachments to the form is quite bad for storage purposes. Now there is a good workaround that involves SmartObjects. Basically the idea is to detach the file data from the form and store the attachment in a SharePoint document library. Once this is done, you can basically store only the document URL link into the InfoPath form.
Eric has a nice video of how this is done. It even has a sample form with the necessary rules required. However, it doesn't show you how to handle multiple attachments and how the initial configuration is done (which might be confusing for newbies).
I have created a document which shows how all this is done (with explanations) from the ground up. In conjunction with Eric's video, I hope this helps anybody out there who is looking at implementing this solution.
Enjoy!
Update (16th Mar 2010)
This is for those people who asked about avoiding duplicate file names. One possible workaround is to put the file attachments into folders. Now uploading a file to a folder is supported with the default broker. Basically you can specify the folder name using the Folder_K2_ServiceDefined field. Now this will fail if the folder does not exists.
So at this point, we just have to figure out how to create the folder before doing the file attachment upload. I found a really easy way to do this without having to add an custom code components. Basically, this is using the out of the box MOSS web service.
Basically create a receive data connection to this web service.
http://<your moss site>/_vti_bin/DWS.asmx
You can then execute the CreateFolder method. For the input parameter, basically it is just <document library name>/<your desired folder name>.
Your data connection should look something like this.

Posted
Tue, Nov 3 2009 6:05 PM
by
johnny