How to simulate for-each loop with K2 workflow?


Originally posted on the K2 Underground on Fri., Nov. 29, 2013 You’re developing in K2 Studio and need to iterate over some data. This document will show you how to create a loop using workflow activities and events.  Create-a-Loop-Using-Workflow-Activities

K2 Blackpearl: Adding URL links to your email message body

Have you run into a scenario where you have to include a URL in the email and when you use <a href> tag in the email body, the generated email link has weird characters (<span> etc) essentially making the URL link invalid. Here are a couple of ways in order to get it to work:

Assume the URL link to use is{Variable} where {Variable} is a K2 defined value or data field etc.

Saving the URL in a data variable and passing it into the email body

Create a data event and set the source as:<a href=”{Variable}”?Google</a>

If you do not include the a href tags, it will NOT work!

Using the HyperLink inline function

In the email body, you can use the HyperLink function to create URL which will have a href tags automatically built in.

Hyperlink function

The one thing that you must be cautious of is when building the URL as it is in an expression format. So you have to “build” the string and treat any field variables as input variable and append it the expression. For example, the expression for the above URL would be:” & {Variable}

Attempts that won’t work

Prior to coming up with the above solutions, I had to try various permutations and below is a list of things that will not work. Hopefully, you will not make the same mistakes:

  1. Adding the <a href=”{Variable}”?Google</a> directly into the message body:
  2.  Creating a data event but the source is missing the <a href> tag
  3. Using the URL decode: This will return the URL but if you directly reference the URL into the message body, you have the same issue.

Happy linking!