Views:

Scenario Overview

In this scenario we need to retry failed system workflows on the Account entity with the workflow named  'Process Accounts' on a daily basis.  

North52 Decision Suite Solution

The North52 Decision Suite solution works like this,

  • A schedule is setup to execute on a daily basis
  • This schedule executes a Global Action
  • The first step of the action is to call a Process Genie formula 
  • This formula will find all failed systems jobs created today with the Workflow named 'Process Accounts'
  • For each record found it will re-execute that workflow

Formula  Steps

The following set of steps outline how to create this Formula

  • Create a new formula of type 'Process Genie'
  • Set the Source Entity to 'N52 Command'
  • Copy & paste the formula below into the formula 
  • Click save

Formula

 ForEachRecord(

   FindRecordsFD('GetFailedProcessAccountSystemJobs'),

   ExecuteWorkflow('Process Accounts', CurrentRecord('regardingobjectid') )

) 

 

Formula Detail Steps

The following set of steps outline how to create this Formula

  • Add a new formula detail record
  • Set the name to 'GetFailedProcessAccountSystemJobs' 
  • Copy & paste the fetch-xml below into the Query field
  • Click save

Fetch-XML

<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
  <entity name="asyncoperation">
    <attribute name="asyncoperationid" />
    <attribute name="name" />
    <attribute name="regardingobjectid" />
    <order attribute="startedon" descending="true" />
    <filter type="and">
      <condition attribute="statuscode" operator="eq" value="31" />
      <condition attribute="name" operator="eq" value="Process Accounts" />
      <condition attribute="createdon" operator="today" />
    </filter>
    <link-entity name="account" from="accountid" to="regardingobjectid" alias="ah"></link-entity>
  </entity>
</fetch>

Action Steps

The following set of steps outline how to create this Formula

  • Create a new Action named 'Retry Failed Process Accounts Workflow new_RetryFailedProcessAccountsWorkflow'    ** 
  • Set it to be a 'Global Action'
  • Add a new step to the Action to call the North52 Process Genie
  • Set the formula shortcode to be the one on the formula you just created, in this case 'dPB'
  • Click Activate

**Note 1 : Please note that the 'Process Name' field on the action must contain as the last word the exact same name as the Unique Name that Microsoft generates for you on the Action.
So for example 'Retry Failed Process Accounts Workflow' becomes 'Retry Failed Process Accounts Workflow new_RetryFailedProcessAccountsWorkflow'
This is due to a bug when you execute fetch-xml to lookup at run-time the unique name of the Action. We logged this bug on Connect with Microsoft but it has yet to be resolved. 

Please consider up-voting this bug at the link below,
https://connect.microsoft.com/site687/feedback/details/806093/unique-name-of-a-process-action-not-returned-correctly-via-fetchxml

Action Setup

 

Process Genie Configuration
 

Details of the Send Email Step

Schedule Steps

The following set of steps outline how to create this Formula

  • Create a new North52 Schedule
  • Set the name to 'Retry Failed Process Accounts Workflow'
  • Set the Frequency field to 'Daily'
  • Set the schedule type to 'Global Action'
  • Set the Workflow field to the name of the Action 'Retry Failed Process Accounts Workflow new_RetryFailedProcessAccountsWorkflow'
  • Set the start time to the desired date & time and click save
  • Finally to start the schedule click N52 Commands -> Start Schedule
  • To verify that it is up and running check the 'System Jobs' view

Schedule Setup 

Wizard - ExecuteWorkflow

Please see below the wizard you can use to create the ExecuteWorkflow() function call used in this formula. 

Note 2 : you will need to have created the Workflow "Process Accounts" beforehand. Also you should copy and paste CurrentRecord('regardingobjectid')  into the Record ID field . 

Did you know?

Automated tests in Dynamics 365 helps with documenting processes

Maintaining automated tests helps you create 'living' documentation of your Dynamics 365 systems, minimizing the potential for frustrating rework.

Building a test validates the requirements, makes it easy to spot ambiguity and incompleteness and can catch defects before they are released. 

As requirements change, tests need to be updated to ensure they continue to validate, thus ensuring the documentation stays up to date.

Learn how TestShield helps automate testing in Dynamics 365