Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / Languages / C#

Create a Workflow in Microsoft Dynamic CRM 4.0

4.92/5 (10 votes)
28 Oct 2011CPOL3 min read 42.2K  
Create a Workflow in Microsoft Dynamic CRM 4.0

What is Workflow?

  • It is a series of steps (methods or functions) which execute sequentially and change the direction of flow based on condition.
  • It is a tool for managing data and processes.
  • It helps to implement standardized Business Processes to help their operation run smoothly and consistently.

Workflow In MSCRM

  • It executed asynchronously.
  • "Microsoft CRM Asynchronous Processing Service" is the Windows service which helps the workflow to execute. It acts as an Host application for the workflow engine to work.
  • Since workflows execute asynchronously, they don't run immediately and depending on the server overhead, it takes some times to complete.

How to Create Workflow in MSCRM

Select the Setting option from Left side of the navigation pane in MSCRM:

Settings--------------->Workflows-------------------->New 

Initiates Workflow in MSCRM

In Microsoft Dynamic CRM, Workflow rules are initiated in three ways which are mentioned below:

  1. Manually by the user
  2. Trigger an event (automatically)
  3. From another Workflow Process (child workflow)

Description of the Above Points

Manually by the User

In this case, User runs the Workflow manually by going to the associated Entity and Clicking the "Run Workflow" button.

Step 1: Select the Setting option from the Left navigation pane in MSCRM:

Setting1.png

Step 2: Select the Workflows:

Setting2.png

Step 3: Select the "New" option, Workflow New Dialog open:

  • Enter the Workflow Name option.
  • Select the Entity option.
  • Select the Type option

CreateWF2.png

Step 4: Click Ok button. The new form will be opened.

In this case, we have to select the "On Demand" option in "Available to Run".

CreateWF3.png

Trigger an Event (Automatically)

The events that triggers the Workflow are mentioned below:

  • Record is created: When a new instance of an Entity is created.
  • Record status changes: When the entity status changed. Some examples are given below:

    EntityStatus
    Accounts Active, Inactive
    Cases Active, Canceled, Resolved
    Contacts Active, Inactive
    Users Disabled, Enabled

  • Record is assigned: Assign the associated entity to the user.
  • Record attributes change: When the attribute of the entity changed.
  • Record is deleted: When the Instance of the associated entity is deleted.

From Another Workflow Process (child workflow)

In this case, we have to select the "As a Child Workflow" option in "Available to Run". Here, the Workflow runs the another Workflow.

Workflow Scope in MSCRM

  • User
  • Business Unit
  • Parent: Child Business Units
  • Organization

When We Used Workflow or Plug-ins

If you need the process to run synchronously, then go for Plug-ins and if you need process to run asynchronously, then go for Workflow.

Creating Workflow in MSCRM

Step 1: Select the Setting option from left side of the navigation pane in MSCRM.

Setting1.png

Step 2: Select the Workflows option:

Setting2.png

Step 3: Select the New option and Set the "Workflow Name","Entity" and "Type".

CreateWF2.png

Click the "Ok" button.

Step 4: Set the values as per requirement.

CreateWF3.png

Step 5: Click On "Add Step" option.

Step3.png

Select the Step as requirement. Following steps are mentioned below:

  • Stage: It is used for grouping purpose and is stored in database
  • Check Condition
  • Wait Condition: Stop the execution of Workflow for a certain period of time
  • Create record
  • Update record
  • Assign record
  • send E-Mail
  • Start Child Workflow: Execute the Child Workflow
  • Change Status
  • Stop Workflow

Step6.png

Step 6: Click Save and Close to continue.

Step 7: Publish the Workflow for activation.

Step8.png

Step 8: Click Ok.

Reference

  • Working with Microsoft Dynamic CRM 4.0 (Author:- Mike Snyder,Jim Steger)
  • Microsoft Dynamic CRM 4.0 Unleashed (Author :- Marc J. Wolenik; Damian Sinay)

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)