让我们来看看官方文档是怎么讲的 https://docs.microsoft.com/en-us/previous-versions/dynamicscrm-2016/developers-guide/gg326836(v=crm.8)

Every time a running plug-in or Workflow issues a message request to the Web services that triggers another plug-in or Workflow to execute, the Depth property of the execution context is increased. If the depth property increments to its maximum value within the configured time limit, the platform considers this behavior an infinite loop and further plug-in or Workflow execution is aborted.

The maximum depth (8) and time limit (one hour) are configurable by the Microsoft Dynamics 365 administrator using the PowerShell command Set-CrmSetting. The setting is WorkflowSettings.MaxDepth. For more information, see, “Administer the deployment using Windows PowerShell” in the Deploying and administering Microsoft Dynamics CRM.

每当一个plugin或者workflow触发了一个请求到web service 并且触发了另一个plugin 和workflow去执行, Depth这个property会增长.如果在规定的时间内增长到最大值,CRM平台会认为这是一个infinit loop, 并且未来的plugin 和 worklow执行将会失败.

depth的最大值为8, 最大时间为1小时.

让我们创建一个ContextDepth.cs 的class

然后把以下的代码复制进去

// The InputParameters collection contains all the data passed in the message request.
if (context.InputParameters.Contains("Target") && context.InputParameters["Target"] is Entity)
{
// Obtain the target entity from the input parameters.
Entity account = (Entity)context.InputParameters["Target"]; try
{
tracingService.Trace(context.Depth.ToString()); if (context.Depth > )
{
return;
} // In case the user removes the value
if (account.Attributes["revenue"] != null)
{
var revenue = ((Money)account.Attributes["revenue"]).Value;
revenue += ; account.Attributes["revenue"] = new Money(revenue);
}
} catch (FaultException<OrganizationServiceFault> ex)
{
throw new InvalidPluginExecutionException("An error occurred in MyPlug-in.", ex);
} catch (Exception ex)
{
tracingService.Trace("MyPlugin: {0}", ex.ToString());
throw;
}
}

让我们使用plugin registeration tool 把这个assembly register到crm中.

让我们改动 annual revenue的值

保存之后,我们发现annual revenue的值已经被更改

最新文章

  1. web前端基础篇⑩
  2. codevs 1163 访问艺术馆
  3. log4j日志
  4. TP复习17
  5. Python教程:连接数据库,对数据进行增删改查操作
  6. mysql 存储过程 计算报表
  7. MySql增加字段、删除字段、修改字段
  8. 8.3 sikuli 集成进eclipse 报错:eclipse中运行提示 Win32Util.dll: Can&#39;t load 32-bit .dll on a AMD 64 bit platform
  9. mysql 赋给用户权限 grant all privileges on
  10. constrain to margins
  11. 【caffe-windows】 caffe-master 之 训练自己数据集(图片转换成lmdb or leveldb)
  12. Mybatis if test 中int判断非空的坑
  13. 与MP3相关的技术总结
  14. Centos6离线安装MySQL5.5.55-1(附带安装包及Perl依赖包)
  15. SpringBoot进阶教程(二十六)整合Redis之共享Session
  16. 蓝桥杯c/c++省赛真题——日志统计
  17. python随笔--复习专用
  18. 小白的CTF学习之路4——内存
  19. Web开发人员vs网页设计师
  20. python入门学习:2.列表简介

热门文章

  1. s5p6818开发板uboot网络开通
  2. 结对作业_core组
  3. Oracle数据库各种名字的区别
  4. java 每间隔一段时间执行一段代码
  5. re正则表达式匹配字符串中的数字
  6. Win32线程——等待另一个线程结束
  7. iOS和小米手机拍照上传后,在web端显示旋转
  8. 大数据 - hadoop三台linux虚拟服务器 - 初始化部署
  9. 微信小程序 image属性 mode
  10. 为UITextField增加MaxLength特性