his one caught me by surprise! I needed to build up a CSV list of email addresses for all previous task owners for an activity, so the simplest way would be to just append the email address each time we get to the task, right? Apparently not.app
Here’s my code:less
K2.ProcessInstance.DataFields["AllApproversEmailAddresses"].Value = K2.ActivityInstanceDestination.User.Email;
Nothing too complicated. However, running it gave me the dreaded (and oh so informative) 「Object reference not set to an instance of an object」. So what’s happening?ui
Well, it’s actually not that complicated. Basically when you create any activity the default destination rule is 「Plan Just Once」 (in fact you don’t even have the option of choosing anything else unless you run the Activity wizard in advanced mode.) Anyway, when this option is chosen the destination instance isn’t actually created, which means that K2.ActivityInstanceDestination will always return null.this
To get around this issue you will need to do the following:rest
That’s it. Hope that helps someone!code