Chapter 12. Advanced Workflow Programming

In Chapter 6, we discussed how Microsoft Dynamics CRM 4.0 uses Windows Workflow Foundation (WF) to execute workflow instances defined by business users. We also looked at developing your own custom activities and how you can register them with the CRM server.

In this chapter, we’ll dig deeper into the workflow implementation within Microsoft Dynamics CRM 4.0 to understand how the software stores workflow definitions within entities in CRM and how you can manipulate these definitions through the Microsoft Dynamics CRM Web services. Additionally, you will gain an understanding of workflow dependencies and how they affect workflow execution. Finally, we’ll explore how CRM uses Extensible Application Markup Language (XAML) and declarative workflows, as well as how you can register your own workflows to execute within CRM.

We’ll cover the following topics in this chapter:

  • Custom workflow manager tool

  • Workflows as entities

  • Declarative workflows

Custom Workflow Manager Tool

To help assist the process of working with workflows, we created a custom desktop application that we refer to as the custom workflow management tool. You can use this application to explore and manipulate workflows on your Microsoft Dynamics CRM server. The tool is named ProgrammingWithDynamicsCrm4.WorkflowManager.exe, and you can find the source code on the book’s companion Web site as detailed in the Introduction. Because this is a desktop application, we don’t step through every line of code; instead, we just take a look at the methods that apply to managing workflows within Microsoft Dynamics CRM 4.0.

Let’s take a quick look at the ProgrammingWithDynamicsCrm4.WorkflowManager user interface to better understand the code samples we’ll be looking at throughout the chapter.

Using ProgrammingWithDynamicsCrm4.WorkflowManager

  1. Download the source code for the book as described in the Introduction.

  2. Open the ProgrammingWithDynamicsCrm.sln solution in Microsoft Visual Studio 2008.

  3. Within the Solution Explorer, right-click the ProgrammingWithDynamicsCrm4.WorkflowManager project, and then select Set As StartUp Project.

  4. Select Start Without Debugging from the Debug menu, or press Ctrl+F5 on the keyboard.

  5. The Connection Details dialog box is displayed, prompting you to specify how to connect to your Microsoft Dynamics CRM server.

    Custom Workflow Manager Tool
  6. Update the CrmService Url field to the correct URL for your Microsoft Dynamics CRM server.

  7. Type your organization name in the Organization field.

  8. If you want to connect to the Microsoft Dynamics CRM server with the credentials that you are currently logged on to Windows with, just leave Interactive User selected. Otherwise you can select Specify Credentials and type in the user name, password, and domain you want to pass to the server. Click OK.

All of the values in the Connection Details dialog box, with the exception of the Password field, are saved when you click OK. You don’t need to enter them every time you use the ProgrammingWithDynamicsCrm4.WorkflowManager tool. If you select Specify Credentials, you must type in the password every time.

After a few seconds, the main ProgrammingWithDynamicsCrm4.WorkflowManager window opens with a list of your current workflows. From here you can perform various operations, such as importing, exporting, and publishing workflow definitions. We examine this functionality as we progress through the chapter.

Custom Workflow Manager Tool
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset