Question:
How do I loop through a keyword field or variable in Workflow Manager?
Answer:
Please be aware of a known limitation when using loops; depending on whether you are using an On-premises or Cloud system, after one task (e.g., condition "loop condition") has been executed a certain number of times without human interaction, the loop detection will be triggered, and the workflow will be unpublished.
*NOTE: The limit for cloud systems is 10 iterations and cannot be altered.
For On-premises organizations, please refer to KBA-36493.
- Create empty tasks, name and connect them. See our example below of how this could be configured.
- Create the following three variables: keywordCount (Numeric), i (Numeric), lineContent (Text)
- Set the loop counter to '0' and get the count of lines in the keyword field.
Workflow global variable = keywordCount = Arithmetic expression = DW_KEYWORD.Count()
Workflow global variable = i =Fixed entry = 0
- In this condition, you check if the loop has to run again or is at its end.
GV_i >= GV_keywordCount
- Inside the loop, you get the text of the line you are processing at the moment and increase the loop counter.
Workflow global variable = line = Arithmetic expression = DW_KEYWORD[GV_i]
Workflow global variable = i = Arithmetic expression = GV_i + 1
KBA is applicable to both Cloud and On-premise Organizations
Beware that using the Count() method works for getting the length of empty keyword fields that are index fields (the example shown uses DW_KEYWORD, which is obviously an index field), but fails when used on empty keyword fields that are global variables with an ArgumentNullException in the workflow designer and with "Fehler in der Systemaktivität: Der Wert darf nicht null sein. Parametername: source" in the Workflow history.
I hope this is helpful to other folks using cloud instances.