When using references in a workflow, you may find that the entire list of items in the reference is returned instead of a single item. This can occur when the reference's list method does not have an input property (filter) to retrieve a single record, so it returns all items in the reference, concatenated together, which is typically not what you need.
For information about using the Create Reference and Loop steps, see the following Help topics:
In this example you are sending an email to all customers in a list. The workflow loops through the email step until all customers on the list have been emailed, after which the workflow continues. In the case where the reference's list method does not contain an input property to identify individual items within the reference, you can use the reference together with the Loop step in order to send a series of emails. This works for other scenarios where you must perform an action in the workflow per item in the reference.
For a typical reference that has a unique identifier, the SmartObject list method has an input property to load a record in the reference, typically an ID, autonumber or GUID, but it could also be a non-key field that acts as a filter on the method. This means that you’re passing a key or filter field as an input to the method, and that the field selected in the Create Reference step is the same as the input on the SmartObject method that you use in the Loop step. If you don’t match these or there is no input property on the method, all rows are returned and concatenated for each iteration of the loop.
The Loop step is designed to use references to retrieve each referenced item's values from the SmartObject when it starts each loop. When there are no more items in the reference, the loop completes.
SmartObject methods, such as the Get List Items by View method for SharePoint used here, do not always contain an input field. You can still configure looping in your workflow using the service object methods by creating a Loop Index and then using this index as the identifier. While SmartBox SmartObject list methods automatically include the input property for passing in the ID, but other SmartObject methods (such as SharePoint, SQL Stored Procedures, and Web Service methods) may not. To use these methods you can do one of the following to perform an action on each individual item within the reference:
Check to see if your SmartObject or service object method that you want to use has an input property. You can do this by following these steps:
The following How to topics guide you through configuring a workflow with a Loop step:
This specific example is no longer applicable from K2 Five 5.3 and K2 Cloud Update 8 onward. There was an issue with the way that workflow references were able to filter when a SmartObject Method does not have the unique property as an input property. This issue was fixed in K2 Cloud Update 8 / K2 Five 5.3. You can use this how-to example in pre-K2 Five 5.3 environments where the issue still exists. Note that the issue also affected other service types, not just SharePoint SmartObjects.