Skip to main content

Two email template inline functions that allows you to configure an template external of K2 workflow. V3 - New feature Smart Buttons. Dynamically display client event actions The templates can reside within SharePoint so that maintenance is easy. The function works by replacing token within the email template. You can also call the smartobject load method to load data on demand For example : The token [ProcessInstance.Originator.DisplayName] within your template will be replaced with the display

ParticipantName is empty

Hi,


I
use GetWorklistTemplate method to generate worklist item notification.


There is an issue when you need to Redirect a worklist item to another person using Client Redirect.


Send notification fires up as expected but ActivityInstanceDestUserFQN remains the one initially set. As a result user receives a wrongly addressed notification "Dear [PI.ADI.User.DisplayName] ... "


So I suspect there are different layers in K2 runtime responsible for Activity instancing and for Worklist Item instancing and the sad thing is that at the moment when SmartFunction is executed Worklist Item is not yet created.


I run few tests and noticed that "Activity Destination Instance/User/Display Name" which is   [ParticipantName] field is empty at the moment of execution of SmartFunction.


Another observation is if you keep default template (no SmartFunctions) with "Dear [ParticipantName]" the name is filled correctly after a redirect.


Did you have a similar issue in your experience ?


Regards,


Dimitri


Re: ParticipantName is empty

I also had the same issue. The destination rule I was using before was "Plan just once". Once I changed it to "Plan per destination (All at once)", it is now working. The Activity Destination Instance/User/Display Name (Participant Name) will display correctly.

Found this page to be helpful:

Differences between "Plan just once" and "Plan per destination"
http://www.k2underground.com/blogs/johnny/archive/2008/07/26/differences-between-plan-just-once-and-plan-per-destination.aspx


Hi All,

 

I have a very annoying and strange issue.

I'm using the email template inline function for a SmartObject Load call.

This has been working great, but lately I get the following error:

Error with smartoject load call '{SMOLoad}ProjectRequest,IT_GP_PMO_ProjectRequests_SMO_ProjectRequests,Load,ID,>ProcessInstance.DataFields.ProjectRequestId]{/SMOLoad}' : SourceCode.SmartObjects.Client.SmartObjectException: Exception of type 'SourceCode.SmartObjects.Client.SmartObjectException' was thrown.
at SourceCode.SmartObjects.Client.SmartObjectClientServer.ExecuteScalar(SmartObject smartObject, DataTable inputTable)
at SourceCode.Field.Core.Helper.Code.K2SmartObjectDAL.CallSmartObjectExecuteMethod(String objectName, String methodName, Dictionary`2 properties)
at SourceCode.Field.InlineFunction.EmailTemplate.Template.GetWorkListTemplate(String template, Int32 procInstID, String originatorUser, String detinationUser, String worklistURL) in C:SourceCode.Field.InlineFunction.EmailTemplateSourceCode.Field.InlineFunction.EmailTemplateTemplate.cs:line 259
Current Context Data
WorklistItemInstance.WorklistItem :
WorklistItemURL :
ProcessInstance.ID : 3393
PI.ID : 3393
ProcessInstance.Nam

 

I know that the problem here is that the ProjectRequestId data field is not being replaced and that causes the error, however, when I view the full error in K2 console I see the value of the data field is in the context so I'm totally confused why it is not being replaced.

By the time the code is at the method to execute the smartobject load call it should have been replaced already.

 

As I said it was working and suddenly stopped working.

Apart from manually doing a find/replace on the template before giving it to the inline function I'm not sure how to resolve this.

 

Any ideas why it is not being replaced?

 

Please advise.

Regards,

JohanL


Dear Adam/All,

Thanks for the post. I actually tried to use the inline functions but it is not working. I changed the email template and code helper solutions to 4.5 framework as my k2 solutions are using framework 4.5, but even its not working. Can you please help me what could be the cause. I followed teh instructions that you provided in word doc.

Appreciate your help.

Regards.


I have been using this funtion successfullly for many monhts on workflows created within K2 Studio. We have started to train business users to build forms and workflows but we are focusing them on using only the k2 Designer web interface for creating workflows and a funny thing is that unlike K2 Studio where you see Originator in the Process Instance and drill down to see fields, when you drag Originator to the funtion you get the originatorUserFQN.

 

In the K2 Designer workflow you see workflow context but only the individuals fields like: Originator Name, Originator full name, Originator Email etc. There is no upper level Originator so I cannot specify a OriginatorUserFQN for the function to work.

 

Has anyone tried to use this inline function in AppIt or the web version of the workflow and know of a work around? We are trying to get the workflow activity into an email and use this to store email templates in SharePoint they way we do with all of our other workflows.

 

 


Hi,
I have a problem with the inline function for a SmartObject call (SQL). If the Smart Object includes a bigint value (64Bit) a Exception will thrown. Is it possible to use the function with 64Bit integer values?
best regards
Jürgen


I have deployed the dll and when I open K2 studio on K2 server either with service account credentials or as anybody else I am able to find the Email template expressions in context browser.

We use remote K2 studio client to connect to K2 server and create workflows. But with this client K2 studio I am not able to locate the same expressions in context browser.

 

Has any body faces this before ? If yes, any work around to get these templates to show up in K2 studio context browser ?


Yes you need to copy the dlls to the workstation with K2 studio installed and restart K2 studio

 

Copy

SourceCode.Field.Core.Helper.dll and SourceCode.Field.InlineFunction.EmailTemplate.dll

into

 

C:Program FilesK2 blackpearlBinFunctions

 

 

Hope this helps


Thanks MickiC, I was able to get this function listed in K2 studio with your input.

I tested these placeholders and I see I was able to get most of thee placeholders replaced with corresponding values except below ones.

 

ProcessInstance.ActivityInstance.User.FQN = ProcessInstance.ActivityInstance.User.FQN]

ProcessInstance.ActivityInstance.User.UserName = ProcessInstance.ActivityInstance.User.UserName]

ProcessInstance.ActivityInstance.User.Name = ProcessInstance.ActivityInstance.User.Name]

ProcessInstance.ActivityInstance.User.Description = ProcessInstance.ActivityInstance.User.Description]

ProcessInstance.ActivityInstance.User.Email = ProcessInstance.ActivityInstance.User.Email]

ProcessInstance.ActivityInstance.User.Manager = ProcessInstance.ActivityInstance.User.Manager]

ProcessInstance.ActivityInstance.User.Sip Account = ProcessInstance.ActivityInstance.User.Sip Account]

ProcessInstance.ActivityInstance.User.Object SID = ProcessInstance.ActivityInstance.User.Object SID]

ProcessInstance.ActivityInstance.User.DisplayName = ProcessInstance.ActivityInstance.User.DisplayName]

 

Any help will be highly appreciated.


Check that you are using the "GetWorklistTemplate" inline function. This one should allow you to get to the ProcessInstance.ActivityInstance.User.XXX variables while the other probably wont work as you are not sending in the DestinationUserFQN.

 

Also check that you are actually in an activity that has a Destination user (task activity) and that the activity is Plan per destination - all at once and Create a slot for each destination. My explantion of this might be a bit fuzzy but the only way to ge the destination user is to make sure the activity creates a slot for each user.

 

You cannot get the destinationUser any other way that I know of. My curiosity is why do you need this because within the activity where you can use this I can only see the usefulness in an escalation and if it is an escalation you have to do it on the event and not the activty. If as I suspect this is an email after the activity you are going to have to go about getting this info directly from the Activities smart object.

 

Hope this helps


Thanks


Thanks a ton MickiC. I was able to get it through and get the emails as required. Next step was to verify I could all the tokens replaced as desired. I could get most of them working except below tokens.

 

>sn] – Serial number i.e. 234_3

0SN=] – Serial number   SN=234_3

0PI.AI.Description] – display the activity description

#PI.AI.Name] - display the activity name

#PI.AI.Priority] - display the activity priority

#PI.AI.MetaData] - display the activity metadata

#PI.E.Description] - display the event description

#PI.E.CredentialUser] - display the event credential user

#PI.E.MetaData] - display the event metadata

#PI.E.Name] - display the event name

#PI.E.Priority] - display the event priority

 

Were you able to get these tokens replaced in your case ?

Thanks again and in advance for your help.


I am sorry I never tried to get these variables but one note is on the serial number. Even on an event escalation I have never been able to get Serial number but it is easy to build it. It is the ProcessID_ActivityInstanceDestID. This once again can only be done within the event escalation and I have never tried to do this with the inline editor. You might also just have empty fields because not all hose fields will have data unless you enter workflow data.

 

If you realy need these fields you might just try to pull them from the workflow reports smartobjects using the Inline editor. It supports calling smart obejcts directly.

 


Hello, 

 

We use this custom inline function extensively in our on-prem K2 4.7 environment as it allowed us significantly more flexibility. However, we are just starting to move to K2 Cloud and are trying to figure out the best way to accomplish something similar without the use of custom inline functions which can no longer be deployed. Does anyone have any ideas/suggestions for this?

 

Thanks


Reply