Use SmartForm Rules to Detect a File Attachment

In K2 SmartForms 4.6.11, there are no rule conditions specific to File Attachment Control events.

— But that doesn’t mean you can’t use them to detect those events.

I have a list view that now uses the Excel Export control. The exporter queries your data source and packages the records inside of a Microsoft Excel® spreadsheet file, which is returned to the user via the File Attachment control. I was looking for a way to programmatically determine, through rule conditions, when a file became attached to the control, but I couldn’t find any such condition.

Fortunately, there is a way.

The File Attachment control has associated with it a Changed() event handler. You may actually use the “When a control … contains a value” Simple Comparison condition to signal the attachment of a file.

In my test, I’ve created the condition and action in a form rule, and the control is located on a view. I used the “When a control on a View contains a value” condition, and set the action to show a message when the condition is met. I then used my reporting engine to return results to the list, and clicked its Export to Excel button to engage the File Attachment object. Once the spreadsheet was attached, I saw my message.

I’m assuming the opposite would be true; that I could detect when an attachment has been removed by using the “When a control … does not contain a value” condition — though I’d probably have to use the former condition (detecting when a file has been attached) to set a flag, and then test for the presence of that flag in the latter, to differentiate signaling the removal of an attachment from, say, the control’s initialization.

Use SmartForm Rules to Detect a File Attachment

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s