I have created a K2 form that allows users to upload up to 10 attachments. Upon submission, these attachments are saved to a SharePoint library using the UploadDocuments
method of the SmartObject.
During the upload process, I check if each attachment control contains a file and then call the UploadDocuments
function accordingly. This process is repeated for all ten attachments.
Now, I need to handle the scenario where a user opens the form in edit mode and wants to update the attachments.
My Attempt:
I tried detecting changes using the rule "When a control in the view raises an action", but this event is triggered as soon as the form retrieves the attachments from SharePoint.
My Question:
- What is the correct approach to updating attachments in the SharePoint library when the form is in edit mode?
- Do I need to delete all existing attachments and re-upload them each time the form is edited, or is there a more efficient method to detect and update only the changed files?
Any guidance or best practices would be greatly appreciated!