This concerns blackpoint and blackpearl (4.5 at least).
Let’s say you stored a list of logins somewhere in your process (maybe in a datafield with a comma separated string or in an XMLField). Now, you want to use it to send an email to each user. Unfortunately, when you set up a K2 mail event, the “To:” field must contain correctly formatted email addresses, so if you drag and drop directly your data, you will have an error at runtime. We can imagine a lot of workarounds for that (“storing an equivalent list of email addresses”, “use AD ServiceObject to get the email addresses”, “write code”…), but they are not very easy to implement.
This need is quite common especially when you create a K2 Sharepoint integrated workflow, because when you use a “person or group” Sharepoint metadata, only the login is stored in the XMLField attached (semicolon separated if multi values are allowed).
So, this can be resolved without writing any line of code configuring a destination rule in “plan per destination” mode for an activity with no client event, only a mail event.
The detailed explanation:
In this example, we will use a datafield called “ListOfLogins” containing something like “domain\user1 ; domain\user2 ; domain\user3”.
- Create an activity specifically for sending the mail.
- Edit the destination rule in advanced mode, and choose the following options:
- Second page: Plan per destination > all at once
- Leave the default values on the third page (Specify the number of slots to be created – 1 – Create a slot for each role and group).
- Forth page: add a new destination set, call it as you want and add the following destination “fx-SPLIT(fx-REPLACE(‘ListOfLogins’,’<replace this by a space>‘,fx-EMPTYSTRING),’;’)”. The replace inline function is used to remove the spaces (automatically added by sharepoint in the case you use “person or group” metadata). The split inline function to get all individual logins. You will have something like that:
- Then you can click finish (twice)
- At this point, with the destination rule implemented, everything within your events will be executed as many times as you have logins in your datafield.
- Now, we just have to configure a mail event, and as we are in a “plan per destination” activity, we can check the “destination user” checkbox (this option allows you to send mail to users specified in the activity destination rule):
- and... that's all. During runtime, my 3 users will receive the email.
More details on “plan per destination”:
I hope this will help you to create better K2 applications ;-).
-- by Jean Cadeau
Thu, Jan 13 2011 7:25 PM