No ratings

Check if File Attachment is empty before saving


When a file is in the middle of being uploaded to a File Attachment control and a user clicks on Save/Create before the upload completes, this can result to the file being saved as NULL or SCNULL.


While you can add a condition and/or a validation on the File Attachment control to check if it is empty before saving it to your SmartObject, as long as you have chosen a file to upload, it will meet this condition even though the file has not finished uploading:



 As a workaround, you may add a Text Area control that will hold the xml value of the file uploaded. Here is an example:


<collection><object><fields><field name='FileName'><value>sample_image.jpg</value></field><field name='FilePath'><value>695BBDF3FFC1C64EAA297EC825856AA9\sample_image.jpg</value></field><field name='FileRequestData'><value></value></field><field name='FileDataURL'><value></value></field></fields></object></collection>


This will be the xml value of the File Attachment control when the file is uploaded. You can then transfer this value to the Text Area control when the File Attachment control is changed:



 Before you call your SmartObject to save this file, please add an advanced condition to ensure that both the File Attachment and Text Area controls are not empty:





Additional Information

This workaround may not be necessary on K2 Five 5.4 and 5.5 as a simple validation on the File Attachment control should suffice.


Related Links

Labels: (2)
Version history
Last update:
‎03-16-2022 02:28 AM
Updated by: