Mail Event: How to include worklist item URL

I am using a email event followed by an infopath client event in an activity to send a user a task.


How can I build up the worklist item url to be added in the email body, i.e thus not use the event notification

option that send out a notification using the K2 email template?



22 replies

I am assuming the task form is also an InfoPath form.

You can put the following in the Mail event:


<a href="http://<ServerName>/RuntimeServices/OpenInfoPathTask.aspx?K2Server=<ServerName>&SN=<ProcessId>_<ActivityInstanceDestId> &XmlFN=<InfoPathFormName>&Lib=<FormLibraryName>&OpenAsWebPage=True&SPURL=<SharePointSiteName>&Single=True" target="_blank">Click here to action your task </a>







Thank for the feedback...But how do I go about doing so?

I can think of...

1. View the code of the email event, and insert the worklist url string build-up code where the body of the message is built up by the event wizard code ?

2. Add a server event in the activity, populate an activity data field with the build-up worklist url string, add it to the email event wizard body without using the view

   code way?


But what should go first? I would presume first the infopath client event so that the task is generated first off course, then a server event to build up the url, then an email event to display the url to the user from an activity data field?


No neccessary to build the string in the server, Brian suggestion is correct and i have done exactly the same. All the variables are available in the context browser. 

Add a email event ahead of your client event and build the anchor tag as suggested by brian.. If you add a mail event after the client event, the activity would wait on the client event untill it is actioned by the user(s). so your mail event which is after the client event would fire only after the client event is complete(which doesn serve the purpose)

Hey maxpirate


 OK, I have given this a try, but with weird results...

I presume the "single" parameter within the url indicate whether to send the task to a single or multiple destinations? I contain both types

within my process. Will just have to change to single-true and single=false I presume?


Email Body: Format HTML

<a href="http://gpr:7000/RuntimeServices/OpenInfoPathTask.aspx?K2Server=gpr&SN=[ProcessID]_[ActivityInstanceDestID]&XmlFN=[InfoPathFormName]&Lib=[SPSLibName]&OpenAsWebPage=True&SPURL=[SPSSiteUrl]&Single=False" target=_"blank">Click here to action your task</a>



HSP k2Server=Integrated=True;IsPrimaryLogin=True;Authenticate=True;EncryptedPassword=False;Host=gpr;Port=5252;k2Process=K2AdvancedDestinationsRoles;xmlFieldName=Roles 01 Data 01 Data;02 Task;03 Task Roles Testing 0 http://GPR:7000/RuntimeServices/K2ViewFlow.asmx False False False &Lib=Roles&OpenAsWebPage=True&SPURL=http://gpr:1000/development&Single=False" target=_"blank">Click here to action your task



1. A very weird looking link is provided as indicated above. Maybe because I did not wrap it into <html> tags?

2. When I open the task from the above produced link, I am able to view the task, but the action dropdown control is missing as if the wrong view

    is displayed or something?

3. When I open the task from SharePoint using the K2 Worklist Web Part, everything is looks fine.


Sorry to say that your assumption is wrong, Single=true has nothing to do with the no of users. It is a parameter for opening the form.

Use proper html formatting in the mail event to see the worklist url link.

Check if you have configured the view properly in order to see the action dropdown list

PS:Use Environment variables for Servername and document libraries so that you can easily switch between environments


Ok, I will not alter the "single" parameter.

I have used proper html now, including a <body>, <table> etc etc but still get a funny looking url. I have checked the view config, there is nothing wrong there. If there was, I would get the same problem when opening it in SharePoint from the K2 web part.

I have also been using environment variables, I just entered the names hard coded in my post to illustrate the format of the message.

Could you maybe post one of your email body sections you have used before that looks fine, because I am going nuts here. Thanks for the help :-)


Can you paste the url that u have embedded in the mail event, and the url that you are getting as output here

Input wizard url...

<a href="http://gpr:7000/RuntimeServices/OpenInfoPathTask.aspx?K2Server=[variable]&SN=[variable]_&XmlFN=[variable]&Lib=[variable]&OpenAsWebPage=True&SPURL=http://gpr:1000/development&Single=False" target="_blank">Click here to action your task</a>


Ouptut email notification...

HSPk2Server=Integrated=True;IsPrimaryLogin=True;Authenticate=True;EncryptedPassword=False;Host=gpr;Port=5252;k2Process=K2AdvancedDestinationsRoles;xmlFieldName=Roles 01 Data 01 Data;02 Task;03 Task Roles Testing 0 http://GPR:7000/RuntimeServices/K2ViewFlow.asmx False False False &Lib=Roles&OpenAsWebPage=True&SPURL=http://gpr:1000/development&Single=False" target="_blank">Click here to action your task

Thats some funny looking link

try this work around

have a string called "link" in the body of the mail event and go to the mail event's code behind and paste this code snippet in the

SetProperties_ExecuteCode(object sender, EventArgs e) method below the

this.EmailMessage.Subject = K2.Configuration.Subject;


url = K2.StringTable["Web Service URL"] + "RuntimeServices/OpenInfoPathTask.aspx?K2Server=" + K2.StringTable["K2Server"] + ":" + K2.StringTable["K2Port"] + "&SN=" + K2.SerialNumber + "&XmlFN=Oracle Security Profile&Lib=" + K2.StringTable["Oracle Forms"] + "&OpenAsWebPage=True&SPURL=" + K2.StringTable["SharepointSite"] + "&Single=True";


string bindurl = "<a href="" + url + "">link to review the request</a>" + "";

this.EmailMessage.Body = K2.Configuration.Body.Replace("link", bindurl);



.EmailMessage.Body = K2.Configuration.Body;

this would surely work

hey maxpirate


i finally got the time to check this out, it worked liked a charm, thanks alot!!


Just another question...will this have any affect when the destination users are a AD group?

this method will work irrespective of the type of destination used. destinations are resolved at runtime and this piece of code gets executed after the resolution


Hi I created my URL exactly in the format that is shown:

http://<workspace_servername>/RuntimeServices/OpenInfoPathTask.aspx?K2Server=<k2 server>&SN=<serial number>&XmlFN=<InfoPath Form Name>&Lib=<MOSS Form Library>&OpenAsWebPage=True&SPURL=<SharePoint Site URL>&Single=True&target=_blank

However when I  open the link I am getting the error below:

A potentially dangerous Request.QueryString value was detected from the client (SN="</span>134<span styl...").

I noticed  <span> tags are being added before and after the Process ID and the Activity Instance Destination ID. When i manually remove the tags in the url, it resolved successfully, so I know that the problem lies there. I  have html selected for the message format. Any ideas of what can be causing this?





the span tags gets genetrated when u try to generate the url of the form from the mail event wizard. You can modify the code of the mail event and insert the required url in the body of the mail(explained in previous posts).

I am using K2 Studio - Blackpoint. I don't think is possible for me to access the code unless is Blackpearl right? So what is the workaround for Blackpoint users I am folloing his instructions to the letter



Any answers for my question above? Thanks

Hi DC,


We have requirement that InfoPath Task form url should be sent to approver in mail and we used below code snippet to generate Task form url in mail (ref :



string url = K2.StringTable["Web Service URL"] + "/RuntimeServices/OpenInfoPathTask.aspx?K2Server="

                        + K2.StringTable["K2Server"] + ":"

                        + K2.StringTable["K2Port"] + "&SN="

                        + K2.ProcessInstance.ID + "_" + K2.ActivityInstance.Destinations[0].ID

                        + "&XmlFN=FreeOfCharge&Lib="

                        + K2.StringTable["RDAP FOCSite"] + "/Form%20Library"

                        + "&OpenAsWebPage=True&SPURL="

                        + K2.StringTable["RDAP FOCSite"]

                        + "&Single=True";

string FormLink = "<a href="" + url + "">link to review the request</a>" + "";


this.EmailMessage.Body = K2.Configuration.Body.Replace ("FormLink", FormLink);


E- Mail is sent to Approver, but when he clicks on the link, it’s opening a blank page L

FYI, this InfoPath form client event has multiple destination users i.e. multiple approvers.  Is this causing an issue?


Please any help?



JayaPrakash N M

The need to construct this URL is unnecessary maintenance overhead. Why isn't there another way?

I finally got it to work in Blackpoint. I created the WHOLE link in a data event and use it in the email. What I mean by WHOLE is that when I build the field in the data event I include the <a> tag as I want it to show up.

I wasn't able to get the worklist link from the data event. The links is supposedly to be as following and I only get the SerialNumber section, but not able to find the WorkflowInstanceID, ListID, ItemID and TaskListId. Is it possible to create a custom e-mail event to send the Worklist to users?



This is what I did to get it to work in K2 studio,

1. Create an environment variable representing everything needed for view flow but the but the process id.  If you can’t create an environment variable then a process variable will do. (I grabbed this from view flow url)


Note that your ports may be different.

2. Create a string process variable to be the final url to use.

3. Use a data event to join the variable from 1 and the proc id and place in the new string variable defined in 2.  Just drop the two values from the object explorer in the source field side by side. 

4. Create the email event and use the url inline function to create the link based on the string process variable created with the data event.

Hope that helps


Hi guys,


its been awhile. regarding on this topic, i tried to use the url construction provided here in thread but unfortunately, there's some minor issue occur. when i clicked the link/url, "There are no worklist items for this user, or the item has already been actioned". i used the email notification in escalation of the default activity.





I know this is an old thread, but I ran into this issue with Outlook adding all the <span> tags around my dynamic url directly within my email activity, so I wanted to contribute with some clarification. Just as a follow up and clarification of  @roeseaj post, I used a Data Event under the Event Wizard tab in Studio. The Source is the entire A HREF tag with your dynamic URL and parameters. The Destination is a new Data Field you create right from within the same Context Browser under Process/Activity Data (snapshot below). Then just add your Data field to your email activity instead. Hope this helps others.





Or even better, I just found out: simply use your own HTML template:




<!doctype html>

<html lang="en">
<meta charset="utf-8">


<a href="SERVER/Form/GrantsInternalForm/?&p_k2_workflow_id=WORKFLOW_ID&p_k2_username=USERNAME">View Internal Grant Proposal.</a>