As a K2 developer, during a K2 Smartforms and workflow project, you may need to specify a ‘send email event’ with an attachment. This could come from either Smartforms or the workflow. However, it may be the case that you don’t want to include the attachment if its size is greater than 10MB. So, how do you find out the size of the SharePoint document, using K2 SmartObject, when the size is not known beforehand?
K2 provides the Sharepoint Functions broker, in which the SharePoint MetaData Service is included:
Let’s make this functionality available via a Smartobject. Right click on the Sharepoint MetaData object under Sharepoint MetaData Service and select ‘Create SmartObject’.
Give your SmartObject an appropriate name and click ‘Publish SmartObject’:
After the SmartObject is created and published, we are ready to invoke it. Locate your SmartObject, under the SmartObject Explorer:
Right click and select ‘Execute SmartObject’. The execution window will open, as seen below.
Change the Method to Execute to ‘Load Document Column Value’ and fill in the Sharepoint Site URL, List Name, Folder (if required), File Name parameters and set the value ‘File_x0020_Size’ for the Column Name. ‘File_x0020_Size’ is the internal site column name associated with a Document Library. Press Execute!
The file size is returned in bytes.
When using this SmartObject from SmartForms or a Workflow, it is always good practise to have the Sharepoint Site URL, Document Library Name and Column Name in an environment field.
In the meantime, I really hope this was helpful. If you have any further issues, please contact us.