This article was created in response to a support issue logged with K2. The content may include typographical errors and may be revised at any time without notice. This article is not considered official documentation for K2 software and is provided "as is" with no warranties.
To create a simple workflow with the HTML designer that will add multiple attachments,
from the attachments OOTB SmartObject to a Library
. We will be pulling the list of items as a single reference
, then use the 'Join' inline function to inject a ";" separator into the list of objects to allow a loop to parse through the single reference, uploading each attachment one at a time.
Before You Begin
Please have a SharePoint list
created with SmartObjects and a workflow
. Additionally, please have a Document Library
ready with SmartObjects to upload the file(s) to.
1. Create a Workflow. If the Workflow is being created not on the list the Attachment SmartObject is on, a 'Create Reference' event will be needed at the beginning to create the Attachment item reference.
2. Create a 'Set Data Fields' event and create a new data field. Where you place the data field's value, go to the Functions tab in the Context Browser and drag the 'Join' function to the data field box.
3. This will cause the Join input properties box to appear. In the 'Separator' box, place a semicolon (;). In the 'Values' box, go to the SmartObjects tab in the context browser. Drill down into the folder structure until you get to the Attachments SmartObject that is currently holding the attachments waiting to be uploaded to the Library. Select the 'Get Attachments | Name' method.
4. When the box appears for the 'Get Attachments | Name' method, choose 'All items as a collection' from the drop-down, and choose the 'ID' field from the main list reference to get the correct 'List Item ID'.
5. After the 'Set Data Fields' event, drag a 'Loop' event from the Logic section. Set the data field variable from the previous 'Set Data Field' as the target for the Loop to loop through.
6. On the 'Next Item' path, add the 'Add Document to Library' event. In the Supply a field box, add the 'Get Attachment | File' method from the Attachment SmartObject. Pick the Document Library to upload to, and then in the Properties section select the Title property to Update. Go to the Functions tab in the Context Browser, expand 'DATE AND TIME', then drag the 'Now' function to the Title property. This will update a piece of metadata with a unique value to allow the loop to work.
7. Have the arrow leaving the 'Add Document to Library' event go back into the Loop event to complete the loop.
8. Lastly, on the 'Complete' path for the loop, either drag a 'Stop' to the workflow or continue building.