K2.ActivityInstanceDestination.User is NULL

本文介绍了一个在K2流程中收集所有任务负责人邮件地址时遇到的问题及解决方案。由于默认活动目的地规则设置为PlanJustOnce,导致无法获取到活动实例目的地对象。通过调整活动目的地规则为AllAtOnce,成功解决了该问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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.

Here’s my code:

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?

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.

To get around this issue you will need to do the following:

  • Right-click the activity to open the activity properties.
  • Click on the Destination Rule Options tab, and then click the ‘Back’ button on the wizard.
  • Check the box which says “Run this wizard in advanced mode”, then click “Next”.
  • You’ll see that “Plan per slot (no destinations)” is selected. Choose “All at once” and then click through the rest of the wizard.
  • Deploy and test.

That’s it. Hope that helps someone!

转载于:https://www.cnblogs.com/rash/p/7693716.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值