Welcome to K2 Underground Sign In | Join | Help
Sending emails to Destination user

File this one under miscellaneous tips, it might come in handy for someone somewhere.

 

The symptoms

  • You want to send an email to the destination user using a standard email event wizard, but the check box for send to destination user remains grayed out and you don't understand why.
  • You use the API in the code behind a server event, client event or in a destination rule or anything and try the following fairly innocent looking code:
    • Console.WriteLine(K2.ActivityInstanceDestination.User.Email.ToString()); or anything similar to do with the ActivityInstanceDestination.User
    • and the above line of code gives you an "object reference not set..." type error.

The Cause

 

The reason why you are seeing the above mentioned symptoms is because by default the new destination rule advanced settings are set such that no destination instances are created (Planned per slot (No destinations) in the advanced wizard). This means that the K2.ActivityInstanceDestination object does not exist and therefore the error you are getting. This is also why the send to destination user is grayed out in the email event template.

 

The Solution

 

So what to do? Plain and simple do the following:

  • run the destination rule wizard for the particular activity
  • click on the first (welcome) screen at the bottom of the wizard to go back to the start.
  • check "Run this wizard in Advanced mode" and click next.
  • On the next page you will see that "Plan per slot" is highlighted. Click on "All at once" which will create standard destinations as in 2003 (do how ever take into account the effect of this if you have a large number of destination users, activity data fields or xml fields, etc, but that is out of scope of this article...)
  • click finish.
  • You can now go back to your email event template and "send to destination user" will be enabled, and your K2.ActivityInstanceDestination API calls will/should work.
Posted: Monday, June 30, 2008 12:37 PM by GLouw

Comments

jchandra said:

Lol, just decided to look around underground blog and found this post.  I blogged about the same stuffs at http://geeks.netindonesia.net/blogs/jimmy/archive/2008/07/10/setting-destination-users-as-mail-event-recipient-in-k2-blackpearl.aspx after fixing the same problem.  Should have looked here first.

# July 17, 2008 2:29 AM
Anonymous comments are disabled