WEBSITE

Sharepoint 2010 : Creating a Workflow Using Visual Studio 2010 - Using the Visual Studio Workflow Designer (part 1)

11/4/2013 3:06:12 AM

With our pluggable workflow service and external calculation engine up and running, we can create a basic workflow in Visual Studio that will send messages to the calculation engine. Our test workflow will be very simple; when a new item is added to a list, its title will be sent to the calculation engine. We will then be able to trigger a response manually from the calculation engine, which will be passed to the workflow. The workflow will log the response and complete.

  1. We can add our workflow to the WorkflowDemonstration solution that we created earlier. In Visual Studio, select Project | Add New Item. From the Add New Item dialog, select SharePoint | 2010 | Sequential Workflow. Name the new workflow External Calculation, as shown:

  2. In the SharePoint Customization Wizard dialog, leave the default name as WorkflowDemonstration - External Calculation. We can see that the same types of workflow that are available in SharePoint Designer are also available for Visual Studio workflows: List Workflow and Site Workflow. Since we’re planning to use data in a list to trigger our workflow, set the type to List Workflow.

  3. Accept the default association settings. This will associate our workflow with the Products list that we created earlier. Click Finish to complete the process.

1. Using the Visual Studio Workflow Designer

When the workflow has been added to the project, the workflow designer tool will be displayed. You can see that its user interface is similar to the one we created earlier using Visio 2010. You can drag workflow activities from the toolbox on to the design surface to build up the workflow logic.

Our workflow needs five additional steps: CallExternalMethod, which can be found in the Windows Workflow v3.0 group in the toolbox; SetState, which can be found in the SharePoint Workflow group; HandleExternalEvent, which can be found in the Windows Workflow v3.0 group; LogToHistoryListActivity, which can be found in the SharePoint Workflow group; and CodeActivity, which can be found in the Windows Workflow v3.0 group.

Drag the required activities onto the designer surface, as illustrated:

Configuring Workflow Activities

You can see from the designer that a few of our activities have not been configured properly. This is indicated by the icon in the upper-right corner of the activity control. Let’s work through them in sequence to set the appropriate configuration details.

CallExternalMethodActivity

Starting with callExternalMethodActivity1, when we select the activity we can see in the Properties pane that the values for InterfaceType and MethodName are invalid as shown. This activity is used to communicate with a pluggable workflow service and in our case will be used to invoke the SubmitCalculation method on our CalculationWorkflowService.

  1. The first property to configure is InterfaceType. This is the interface that we tagged earlier with the ExternalDataExchange attribute. Click the ellipsis to show the Browse and Select a .NET Type dialog. The IExternalCalculationService is already selected since it’s the only interface in our solution with the appropriate attribute. Click OK to use this.

  2. Now the MethodName property needs to be configured. From the drop-down list, select SubmitCalculation. The values in the drop-down list are populated from the InterfaceType by using reflection. Since SubmitCalculation is the only method on our interface, it is the only item in the list.

  3. Once SubmitCalculation has been selected, a new property appears: product. The property is added automatically since it appears in the list of arguments for the SubmitCalculation method. For out test workflow, we’ll set this to the title of the list items on which the workflow has been started. Click the ellipsis to show the Bind dialog, an important part of the workflow designer because it allows us to bind properties to local variables or other properties. We can add new variables by selecting the Bind To A New Member tab if required. For our purposes, we need to bind the product property to the Title property of the current workflow item. Expand workflowProperties | Item | Title, and then click OK to store the binding.

Other  
  •  Sharepoint 2010 : Creating a Pluggable Workflow Service (part 6) - Calling a SharePoint-Hosted WCF Service
  •  Sharepoint 2010 : Creating a Pluggable Workflow Service (part 5) - Calling a WCF Service, Receiving WCF Messages , Raising Events in a Workflow Service, Configuring Pluggable Workflow Services
  •  Sharepoint 2010 : Creating a Pluggable Workflow Service (part 4) - Using the ExternalDataExchange Attribute, Deriving from SPWorkflowExternalDataExchangeService
  •  Sharepoint 2010 : Creating a Pluggable Workflow Service (part 3) - Hosting an .svc File in SharePoint, Token Replacement in Visual Studio , Adding WCF Service Configuration to SharePoint
  •  Sharepoint 2010 : Creating a Pluggable Workflow Service (part 2) - Add a SharePoint-Hosted WCF Service
  •  Sharepoint 2010 : Creating a Pluggable Workflow Service (part 1) - Create a Windows Forms Client Hosting a WCF Service
  •  PowerShell for SharePoint 2013 : Word Automation Services - Disable Word 97–2003 Document Scanning , Disable Embedded Fonts in Conversions
  •  PowerShell for SharePoint 2013 : Word Automation Services - Modify Job Monitoring, Modify Conversion Timeouts
  •  PowerShell for SharePoint 2013 : Word Automation Services - Configure Supported Document Formats for Conversion, Modify Database Information
  •  PowerShell for SharePoint 2013 : Word Automation Services - Configure the Conversion Processes, Configure Conversion Throughput
  •  
    Top 10
    Review : Sigma 24mm f/1.4 DG HSM Art
    Review : Canon EF11-24mm f/4L USM
    Review : Creative Sound Blaster Roar 2
    Review : Philips Fidelio M2L
    Review : Alienware 17 - Dell's Alienware laptops
    Review Smartwatch : Wellograph
    Review : Xiaomi Redmi 2
    Extending LINQ to Objects : Writing a Single Element Operator (part 2) - Building the RandomElement Operator
    Extending LINQ to Objects : Writing a Single Element Operator (part 1) - Building Our Own Last Operator
    3 Tips for Maintaining Your Cell Phone Battery (part 2) - Discharge Smart, Use Smart
    REVIEW
    - First look: Apple Watch

    - 3 Tips for Maintaining Your Cell Phone Battery (part 1)

    - 3 Tips for Maintaining Your Cell Phone Battery (part 2)
    VIDEO TUTORIAL
    - How to create your first Swimlane Diagram or Cross-Functional Flowchart Diagram by using Microsoft Visio 2010 (Part 1)

    - How to create your first Swimlane Diagram or Cross-Functional Flowchart Diagram by using Microsoft Visio 2010 (Part 2)

    - How to create your first Swimlane Diagram or Cross-Functional Flowchart Diagram by using Microsoft Visio 2010 (Part 3)
    Popular Tags
    Microsoft Access Microsoft Excel Microsoft OneNote Microsoft PowerPoint Microsoft Project Microsoft Visio Microsoft Word Active Directory Biztalk Exchange Server Microsoft LynC Server Microsoft Dynamic Sharepoint Sql Server Windows Server 2008 Windows Server 2012 Windows 7 Windows 8 Adobe Indesign Adobe Flash Professional Dreamweaver Adobe Illustrator Adobe After Effects Adobe Photoshop Adobe Fireworks Adobe Flash Catalyst Corel Painter X CorelDRAW X5 CorelDraw 10 QuarkXPress 8 windows Phone 7 windows Phone 8