Notification Email


Badge +3

Hi,


I would like to send notification email to destination user, but I have template used for this workflow type only, so I was suggested to use Email Event Wizard instead of notification email since modifying email template will effect to all notification email in all workflows in this server.


I don't want to paste HTML in all Email Event Wizard because if changes are made and I have to change all Email Event Wizards one by one (and I have so many of them...), but how can I create and apply template for all of Email Event Wizards in the workflow


I just think that can I use web service as SmartObject to generate email content?


All data in email I want are


1. first action of destination user


2. url with serial number


3. some fields in process instance data fields


but I can't find how to get url with serial number if I code in web service using K2 API


So... my questions are


1. Using web service generating email content is good idea? if not, please suggest


2. if yes, how can I get url with serial number defined in client event wizard...


thanks for any suggestions


 


4 replies

Badge +5

You're going to have to write code, so one approach would be to store an HTML template in a SharePoint list, database table, etc. as a string.  Put placeholders in the template such as [URL], [SerialNumber], etc. so it will be easy to replace those sections in code.  In the code behind of the Email Event, download the desired template, set the 'Body' property of the email to the string you just downloaded (I would use SmartObjects), and then do a String.Replace() to replace each of the placeholder values with values from the process.

Badge +4

Here's a quick example what erice was talking about. This example is building a link to the worklist item for the email. I'm using the String Table so I can avoid hard coding the environment in the string, due to different staging environments, multiple servers etc.


string url = K2.StringTable["Web Service URL"] + "/RuntimeServices/OpenInfoPathTask.aspx?K2Server=" + K2.StringTable["K2 Server"] + ":" + K2.StringTable["K2 Port"] + "&SN=" + K2.SerialNumber + "&XmlFN=OrbitSignature&Lib=Signature Forms&OpenAsWebPage=True&DeployBrowserEnable=True&SPURL=" + K2.StringTable["SharePointEnvironment"] + "&Single=False";

this.EmailMessage.Body = K2.Configuration.Body.Replace("[here]", string.Format("<a href="{0}">here</a>", url));

Badge +3

thanks for your replies :)


But I still have some questions


1. Do you mean I have to add SmartObject Event and go to "View Code" of Mail Event, change code for replacing strings and copy these 2 Events to all activities in the workflow, Am I correct?


2. Is there any way to get "first action" in the Client Event of that activity? my client would like to have message like "please [action] this task" or something like this but I still cannot find the way to get actions for incoming Client Event.


thank you in advance

Badge +3

Now I still have questions.......


1. How to get "first action" in Client Event of that activity?


2. I have to construct URL all over again? I have some activity that send some additional query string parameter, so I have to add those parameter one by one activity? Is there any way to get the exact URL from Client Event of that activity?


anyone please help...

Reply