Skip to content

用C#扩展后端功能

  • 什么场景需要用C#扩展后端功能?
  • 比如订单发货后需要自动扣减库存,用现有的功能无法实现,用Power Automate也无法实现(因为Power Automate只能读取现值、无法获得改动前的值),这时就必须用C#写后端逻辑了。
  • 用C#扩展后端逻辑有两种方式:plugin 和 custom workflow activity。这两种方式都要编译为dll,用PluginRegistrationTool上传到dataverse中的。
  • 如何使用PluginRegistrationTool,见 使用PRT

plugin vs custom workflow activity

  • 这两种方式的区别:One difference between the two is that for custom workflow activity assemblies, you register just the assembly. For plug-ins, you register the plug-in assembly and one or more steps per plug-in.
  • workflow activity的好处是可以重新安排顺序
  • 根据文档中的说法,workflow运行速度比plugin慢。
  • workflow无法cancel请求,plugin在PreValidation stage可以cancel掉请求。
  • workflow和plugin的触发时机不同。plugin在event pipeline中执行。workflow不在pipeline中执行,workflow的执行时机是:before pipeline或after pipeline。
  • 关于event pipeline的描述见Event Framework

官方文档

  • 2016版SDK中的Dynamics365SDK.chm
  • https://docs.microsoft.com/en-us/powerapps/developer/data-platform/write-plug-in