Issue

When you use a form containing a list view of attachments, and you leave the form open for longer than an hour without submitting it, the following error occurs:

Error: SmartObject property FileLeafRef is a required property for selected method AddAttachment. FileName property must be set

The item gets saved to the SharePoint list but without the attachments. Subsequent configured rules, such as start the workflow, do not execute.

Cause

Attachments are kept in temporary storage for one hour, so when you submit the form after this period of time, the error occurs because the attachments are no longer in memory.

Workaround

It is recommended to keep values set to one hour (3600 seconds) and make sure you submit the form within one hour to prevent the error. If this is not possible, you can change the default value in the configuration files mentioned below.

In a K2 Five environment, a K2 administrator must manually edit the configuration. If you are working in a K2 Cloud environment, you will not have direct access to change the configuration files. If you need assistance to change these values, please log a support ticket.

Change Isolated Storage setting on the web server

When you upload a file to the k2 server, it stores it on the file system of the web server in the isolated storage location.

Open the Web.config file  at <install drive>:\Program Files\K2\K2 smartforms Runtime\ and modify or add the following keys using your own values for interval and age (in seconds):

  • <add key="Forms.Runtime.UseIsolatedStorage" value="true" />
  • <add key="Forms.Runtime.DeleteTempFiles.Interval" value="300" />
  • <add key="Forms.Runtime.DeleteTempFiles.Age" value="3600" />

If not specified, the default values are used.

Update the FormFile table in the K2 database in load-balanced scenarios

If you have multiple SmartForm servers deployed in a load-balanced configuration, the request to save the file does not occur on the same server to which the file was uploaded. Since isolated storage is only available on the local machine, you need a secondary shared location for load-balanced servers. In this case, K2 saves the uploaded file in the K2 database. If the file is not found in isolated storage on a local machine, it is submitted from the database location.

Open the K2HostServer.exe.config file located at <install drive>:\Program Files\K2\Host Server\Bin\ and modify or add the following keys using your own values for interval and age (in seconds):

  • <add key="Forms.Runtime.PurgeFiles.Enabled" value="true" />
  • <add key="Forms.Runtime.PurgeFiles.Interval" value="300" />
  • <add key="Forms.Runtime.PurgeFiles.Age" value="3600" />

By default, files are deleted after one hour (3600 seconds).

You must restart K2 server for these changes to take effect.