简体   繁体   English

CRM 2011插件-在创建任务时获取状态码

[英]CRM 2011 Plugin - Get the Statecode on create of a task

I have a plugin registered on Post of Task creation, I am trying to check the RegardingObject, ActualMinutes field and State Code of the task, however, the StateCode always seems to return 0 when creating a new task (even if you choose mark complete). 我在创建任务后注册了一个插件,我正在尝试检查任务的RegardingObject,ActualMinutes字段和状态代码,但是,在创建新任务时,StateCode似乎总是返回0(即使您选择标记为完成) 。

Does anyone know how to work around this issue? 有谁知道如何解决此问题?

OptionSetValue statecode = (OptionSetValue)entity["statecode"];
if (entity.Attributes.Contains("regardingobjectid") && entity.Attributes.Contains("actualdurationminutes") && statecode.Value == 1)
                { //DO STUFF }

Thanks! 谢谢!

My guess would be that when using " Mark as complete ", CRM saves the Task first and then uses a separate SetStateRequest to mark it as complete. 我的猜测是,当使用“ 标记为完成 ”时,CRM首先保存任务,然后使用单独的SetStateRequest将其标记为完成。 Which means you'll never be able to get other StateCode then 0 at that point in time in your post-create event. 这意味着在创建后事件中,您将永远无法获得当时为0的其他StateCode。

I think you'll have to hook the plugin onto the update event on Task and check if that cracks it for you. 我认为您必须将插件挂接到Task的update事件上,并检查是否可以帮您破解。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM