创建一个dynamics CRM workflow (一) - Introduction to Custom Workflows

Workflow:

Use this process to model and automate real world business processes. These processes can be configured to run in the background or in real time and can optionally require user input. Workflow processes can start automatically based on specified conditions or can be started manually by a user.

简单一句话总结, workflow可以实现自动化.

Action:

Use this process to create a new operation that is not available in a standard Microsoft Dynamics CRM installation or to combine multiple disparate operations into a single operation. 

Action是workflow中的动作

什么时候使用Workflow来代替plugin

大部分时候使用workflow的骚操作也是可以用plugin来实现. 但是一下两个情况你可以用workflow来实现

- 在business logic当中的改变做更改的人是普通用户而不是开发者,或者换一句话来说是这些改动不应该是依赖开发者去做.

- 需要让用户去手动触发这些workflow 逻辑. 用户可以在form中或者grid中手动自己触发而不是设置好的触发程序.

Workflow的 life cycle

 1. 当workflow创建的时候, workflow是在draft状态. 如果需要使用workflow,必须activate workflow才可以运行. 当workflow被activate之后, 这个workflow会被subscribe到一个特定的CRM events. 当这些events在CRM中被trigger之后, workflow的snapshot快照dependencies(附属)和input parameters 会被创建, 并且新的async operation 操作被添加到async service queue Manager当中. async operation 代表 workflow 执行的工作 并且在queue中等待执行, 一直保持ready 状态.

2. 当async operation 开始执行, windows workflow foundation run-time engine 会创建一个workflow instance, 并且关联到这个operation中, 并且state会从ready改变成locked.

3. async operation 和 workflow instance 在每一个transition一起update 当async operation blocked的时候, windows workflow foundation run-time engine 把workflow instance 放到 suspended 状态, 并且从memory移除. 当suspended 状态 satisfied, workflow instance 重新加载到memory中.

4. 当workflow instance 的状态改为 ready 的时候,  workflow 执行状态会改为locked. 在一般的案例中, workflow instance 移到 completed 状态 当所有的workflow activities completed.

Workflow 小tips

Dynamics CRM中有basic workflow logic 可以实现简单的功能

如果想要实现更高级的功能, 需要用代码来extend basic workflow.

Custom workflow Activities default设定是async. 手动可以调节为sync模式

custom workflow activities是在system main event 执行之后才开始执行

数据交互会稍微比较慢

猜你喜欢

转载自www.cnblogs.com/TheMiao/p/10798583.html