MS CRM:检查子工作流的状态

MS CRM: Check the status of a child workflow

我正在设计一些工作流程。主工作流调用一些子工作流。如果子工作流失败,我需要等待一段时间,然后重新运行该子工作流。如果再次失败,则将任务发送到队列。 我无法检查子工作流程的状态。当它失败时,我将停止状态为已取消的子工作流。

您可以创建查询异步操作 table 并检查 child 工作流状态的自定义工作流步骤。

查询以获取 child 工作流的状态:

<?xml version='1.0' encoding='utf-8'?>
<fetch distinct='false' no-lock='false' mapping='logical' page='1' count='100'>
  <entity name='asyncoperation'>
    <attribute name='statuscode' />
    <filter type='and'>
      <filter type='and'>
        <condition attribute='correlationid' operator='eq' value='{Correlation ID of workflow>' />
        <condition attribute='name' operator='eq' value='NAME OF CHILD WORKFLOW' />
      </filter>
    </filter>
  </entity>
</fetch>

这是示例查询,按名称和相关 ID 匹配 child。如果您只调用一次 child 工作流,它将起作用。

在这里您可以找到异步进程的状态值列表:https://msdn.microsoft.com/en-us/library/gg309288.aspx

那么主要的工作流程步骤如下:

  • 调用child工作流程
  • 稍等
  • 调用自定义步骤来检查 child 工作流的状态
  • 如果 child 状态正常 - 继续 main
  • 如果不添加逻辑来处理失败