nintex workflow 2007 sdk 1.1

Upload: farhad-javanmardi

Post on 07-Apr-2018

386 views

Category:

Documents


3 download

TRANSCRIPT

  • 8/6/2019 Nintex Workflow 2007 SDK 1.1

    1/214

    Nintex Workflow 2007Software Development Kit

  • 8/6/2019 Nintex Workflow 2007 SDK 1.1

    2/214

    Page 2 of 214www.nintex.com [email protected] connect.nintex.com

    2008 Nintex LLC, All rights reserved. Errors and omissions excepted.

    Software Development Kit v1.1

    OVERVIEW

    Welcome to the Nintex Workflow 2007 Software Development Kit (SDK). This document is intended for developers and

    includes API documentation as well as technical "how to's" and code examples.

    This SDK will be updated to include new API documentation and practical examples as they become available. Please submitall feedback [email protected].

    To download the latest version of the Nintex Workflow 2007 software development kit and supporting resources please see

    http://www.nintex.com/Nproducts/Workflow2007SDK.aspx.

    WHATS NEW?

    Article about creating custom inline functions. Web service method to create a workflow export file. Web service method to delegate a single task. Added reference to IsAllowed method in tutorial for creating a custom action. Added an example project of a custom task response form. Added appendix information about starting a workflow with the SharePoint API and how to format start data when

    starting workflows programmatically.

    Example solution for deploying a Nintex Workflow as part of a SharePoint solution package (WSP). Example solution for deploying a custom workflow action as part of a SharePoint solution package (WSP).

    mailto:[email protected]:[email protected]:[email protected]://www.nintex.com/Nproducts/Workflow2007SDK.aspxhttp://www.nintex.com/Nproducts/Workflow2007SDK.aspxhttp://www.nintex.com/Nproducts/Workflow2007SDK.aspxmailto:[email protected]
  • 8/6/2019 Nintex Workflow 2007 SDK 1.1

    3/214

    Page 3 of 214www.nintex.com [email protected] connect.nintex.com

    2008 Nintex LLC, All rights reserved. Errors and omissions excepted.

    Software Development Kit v1.1

    SUPPORT RESOURCES

    This section lists a range of software required to successfully develop for and extend Nintex Workflow.

    Nintex Connect

    The Nintex Connect site provides a forum for discussing the use and development of Nintex Workflow 2007, along with

    additional examples and downloads.

    Download:http://connect.nintex.com

    Microsoft .NET Framework 3.0 Redistributable Package

    The Microsoft .NET Framework version 3.0 redistributable package installs the common language runtime and associated

    files required to run applications developed to target the .NET Framework 3.0.

    Download:http://www.microsoft.com/downloads/details.aspx?FamilyId=10CC340B-F857-4A14-83F5-

    25634C3BF043&displaylang=en

    Visual Studio 2005 extensions for .NET Framework 3.0 (Windows Workflow Foundation)

    This addin provides developers with support for building workflow-enabled applications using Windows Workflow

    Foundation. Compatible with the released versions of the 2007 Microsoft Office system, Microsoft Windows Vista, and the

    .NET Framework 3.0 Runtime Components.

    Download:http://www.microsoft.com/downloads/details.aspx?FamilyId=5D61409E-1FA3-48CF-8023-

    E8F38E709BA6&displaylang=en

    Microsoft Visual Studio 2005 Team Suite Service Pack 1

    This download installs Service Pack 1 for Microsoft Visual Studio 2005 Standard and Professional, and Team editions.

    Download:http://www.microsoft.com/downloads/details.aspx?FamilyId=BB4A75AB-E2D4-4C96-B39D-

    37BAF6B5B1DC&displaylang=en

    Visual Studio 2005 Service Pack 1 Update for Windows Vista

    The Visual Studio 2005 Service Pack 1 Update for Windows Vista addresses areas of Visual Studio impacted by Windows

    Vista enhancements.

    Download:http://www.microsoft.com/downloads/details.aspx?FamilyID=90e2942d-3ad1-4873-a2ee-

    4acc0aace5b6&displaylang=en

    http://connect.nintex.com/http://connect.nintex.com/http://connect.nintex.com/http://www.microsoft.com/downloads/details.aspx?FamilyId=10CC340B-F857-4A14-83F5-25634C3BF043&displaylang=enhttp://www.microsoft.com/downloads/details.aspx?FamilyId=10CC340B-F857-4A14-83F5-25634C3BF043&displaylang=enhttp://www.microsoft.com/downloads/details.aspx?FamilyId=10CC340B-F857-4A14-83F5-25634C3BF043&displaylang=enhttp://www.microsoft.com/downloads/details.aspx?FamilyId=10CC340B-F857-4A14-83F5-25634C3BF043&displaylang=enhttp://www.microsoft.com/downloads/details.aspx?FamilyId=5D61409E-1FA3-48CF-8023-E8F38E709BA6&displaylang=enhttp://www.microsoft.com/downloads/details.aspx?FamilyId=5D61409E-1FA3-48CF-8023-E8F38E709BA6&displaylang=enhttp://www.microsoft.com/downloads/details.aspx?FamilyId=5D61409E-1FA3-48CF-8023-E8F38E709BA6&displaylang=enhttp://www.microsoft.com/downloads/details.aspx?FamilyId=5D61409E-1FA3-48CF-8023-E8F38E709BA6&displaylang=enhttp://www.microsoft.com/downloads/details.aspx?FamilyId=BB4A75AB-E2D4-4C96-B39D-37BAF6B5B1DC&displaylang=enhttp://www.microsoft.com/downloads/details.aspx?FamilyId=BB4A75AB-E2D4-4C96-B39D-37BAF6B5B1DC&displaylang=enhttp://www.microsoft.com/downloads/details.aspx?FamilyId=BB4A75AB-E2D4-4C96-B39D-37BAF6B5B1DC&displaylang=enhttp://www.microsoft.com/downloads/details.aspx?FamilyId=BB4A75AB-E2D4-4C96-B39D-37BAF6B5B1DC&displaylang=enhttp://www.microsoft.com/downloads/details.aspx?FamilyID=90e2942d-3ad1-4873-a2ee-4acc0aace5b6&displaylang=enhttp://www.microsoft.com/downloads/details.aspx?FamilyID=90e2942d-3ad1-4873-a2ee-4acc0aace5b6&displaylang=enhttp://www.microsoft.com/downloads/details.aspx?FamilyID=90e2942d-3ad1-4873-a2ee-4acc0aace5b6&displaylang=enhttp://www.microsoft.com/downloads/details.aspx?FamilyID=90e2942d-3ad1-4873-a2ee-4acc0aace5b6&displaylang=enhttp://www.microsoft.com/downloads/details.aspx?FamilyID=90e2942d-3ad1-4873-a2ee-4acc0aace5b6&displaylang=enhttp://www.microsoft.com/downloads/details.aspx?FamilyID=90e2942d-3ad1-4873-a2ee-4acc0aace5b6&displaylang=enhttp://www.microsoft.com/downloads/details.aspx?FamilyId=BB4A75AB-E2D4-4C96-B39D-37BAF6B5B1DC&displaylang=enhttp://www.microsoft.com/downloads/details.aspx?FamilyId=BB4A75AB-E2D4-4C96-B39D-37BAF6B5B1DC&displaylang=enhttp://www.microsoft.com/downloads/details.aspx?FamilyId=5D61409E-1FA3-48CF-8023-E8F38E709BA6&displaylang=enhttp://www.microsoft.com/downloads/details.aspx?FamilyId=5D61409E-1FA3-48CF-8023-E8F38E709BA6&displaylang=enhttp://www.microsoft.com/downloads/details.aspx?FamilyId=10CC340B-F857-4A14-83F5-25634C3BF043&displaylang=enhttp://www.microsoft.com/downloads/details.aspx?FamilyId=10CC340B-F857-4A14-83F5-25634C3BF043&displaylang=enhttp://connect.nintex.com/
  • 8/6/2019 Nintex Workflow 2007 SDK 1.1

    4/214

  • 8/6/2019 Nintex Workflow 2007 SDK 1.1

    5/214

  • 8/6/2019 Nintex Workflow 2007 SDK 1.1

    6/214

    Page 6 of 214www.nintex.com [email protected] connect.nintex.com

    2008 Nintex LLC, All rights reserved. Errors and omissions excepted.

    Software Development Kit v1.1

    SUPPLIED EXAMPLES

    This example contains two InfoPath forms, the first is a completed version which has all the business logic integrated and

    the second is a shell form only containing the UI elements.

    Files

    1. {SDK Location}\Examples\InfoPathExpenseIntegration\expenses_full.xsn2. {SDK Location}\Examples\InfoPathExpenseIntegration\expenses_basic.xsn

    STEPS AND PROCEDURES

    This example will use expenses_full.xsn as a starting point; this file can be found in the directory for the example.

    Step 1Form Data

    1. Add the groups below in the Main data source, these groups will be used to logically store the data.Group Name Parent Repeating

    Items expenseReport No

    Item Items Yes

    Employee expenseReport No

    ExpenseForm expenseReport No

    ExpenseApproval expenseReport No

    Tip: How to add a group

    1. From the Task Pane, select Data Sources.2. Right click on the top group, and select Add.3. In the Name field enter the group name.4. Select Group from the Type field.5. Click Ok.

    6. Add the following fields to the corresponding groups in the Main data source.Field Name Group Type

    Date Item Date

    Description Item String

    Amount Item DecimalTotal Items Decimal

    ID Employee String

    Name Employee String

    Email Employee String

    Department Employee String

    Submitted ExpenseForm True/False

    ExpenseState ExpenseForm String

    FileUrl ExpenseForm String

    WorkflowStatus ExpenseForm String

    AllowEditing ExpenseForm True/False

    AllowApproval ExpenseForm True/FalseComments ExpenseApproval Rich Text

  • 8/6/2019 Nintex Workflow 2007 SDK 1.1

    7/214

    Page 7 of 214www.nintex.com [email protected] connect.nintex.com

    2008 Nintex LLC, All rights reserved. Errors and omissions excepted.

    Software Development Kit v1.1

    Image of data source with fields

    Tip: How to add a field

    1. From the Task Pane, select Data Sources.2. Right click on the required group, and select Add.3. In the Name field enter the field name.4. Select the required field type from the Type field.5. Click Ok

    Step 2Form UI

    The figure below shows the empty form that the next section will use as a base. This form can be found in the solution

    files for this example.

    Figure: expense_basic.xsn from the solution files, the basic layout only.

  • 8/6/2019 Nintex Workflow 2007 SDK 1.1

    8/214

  • 8/6/2019 Nintex Workflow 2007 SDK 1.1

    9/214

    Page 9 of 214www.nintex.com [email protected] connect.nintex.com

    2008 Nintex LLC, All rights reserved. Errors and omissions excepted.

    Software Development Kit v1.1

    Figure: The completed design of the InfoPath form.

    Step 3Data Connections

    1. Add a new data source to receive the current workflow tasks for the current user from a web service.a. Click the Tools menu and select Data Connectionsb. Click Addc. Select Create a new data connection to: and select Receive data. Click Nextd. Select Web service and click Nexte. Enter the URLhttp://development.nintex.com/_vti_bin/nintexworkflow/workflow.asmx?WSDL,

    remembering to replacehttp://development.nintex.comwith a url to a teamsite in your environment.Click Next

    f. From the selection of operations select GetRunningWorkflowTasksForCurrentUser. Click Nextg. Click Nexth. When asked to store a copy of the data in the form template, ensure this is not selected as it is not

    required and could cause issues. Click Next

    i. When asked if the form must automatically retrieve data when it is opened ensure this is not selected.Click Finish.

    2. Add a new data source to process the workflow task (approve/reject) for the current user from a web service.a. From the file menu click Tools -> Data Connectionsb. Click Addc. Select Create a new data connection to: and select Receive data, click Nextd. Select Web service and click Nexte. Enter the URLhttp://development.nintex.com/_vti_bin/nintexworkflow/workflow.asmx?WSDL. Click Nextf. From the selection of operations select ProcessTaskResponse. Click Nextg. Click Nexth. When asked to store a copy of the data in the form template, ensure this is not selected, as it is not

    required, and would cause issues. Click Next

    i. When asked if you want to automatically retrieve data when the form is opened ensure this is notselected, click Finish.

    http://development.nintex.com/_vti_bin/nintexworkflow/workflow.asmx?WSDLhttp://development.nintex.com/_vti_bin/nintexworkflow/workflow.asmx?WSDLhttp://development.nintex.com/_vti_bin/nintexworkflow/workflow.asmx?WSDLhttp://development.nintex.com/http://development.nintex.com/http://development.nintex.com/http://development.nintex.com/_vti_bin/nintexworkflow/workflow.asmx?WSDLhttp://development.nintex.com/_vti_bin/nintexworkflow/workflow.asmx?WSDLhttp://development.nintex.com/_vti_bin/nintexworkflow/workflow.asmx?WSDLhttp://development.nintex.com/_vti_bin/nintexworkflow/workflow.asmx?WSDLhttp://development.nintex.com/http://development.nintex.com/_vti_bin/nintexworkflow/workflow.asmx?WSDL
  • 8/6/2019 Nintex Workflow 2007 SDK 1.1

    10/214

    Page 10 of 214www.nintex.com [email protected] connect.nintex.com

    2008 Nintex LLC, All rights reserved. Errors and omissions excepted.

    Software Development Kit v1.1

    3. Add a new data source to submit the form to a SharePoint library.a. From the file menu click Tools -> Data Connectionsb. Click Addc. Select Create a new data connection to: and select Submit data, click Nextd. Select To a document library on a SharePoint site, and click Nexte. Enter the URLhttp://development.nintex.com/myformlibrary, click Next (please note that the form library

    myformlibrary is a standard Form Library with no extra columns).

    f. For the File name enter the function concat("Expenses - ", now(), " - ", userName()). click Nextg. Click Finish.

    Step 4Business Logic (Rules)

    1. Configure the open behavior for the form:a. From Tools | Form Options select Open and Save, the click on Rulesb. Add the rules outlined below. Use the Field Name References row as a fully qualified field reference. This

    will allow you to find the correct field in the Main data source.

    Name Load Workflow Information

    Conditions FileUrl !=

    Actions 1. Set a fileUrl = FileUrl2. Query using a data connection: GetRunningWorkflowTasksForCurrentUser

    Field Fully

    Qualified

    References

    fileUrl = GetRunningWorkflowTasksForCurrentUser/dfs:myFields/dfs:queryFields/

    tns:GetRunningWorkflowTasksForCurrentUser/tns:fileUrl

    fileUrl = /my:expenseReport/my:ExpenseForm/my:FileUrl

    Figure: Screenshot from InfoPaths logic inspector

    http://development.nintex.com/myformlibraryhttp://development.nintex.com/myformlibraryhttp://development.nintex.com/myformlibraryhttp://development.nintex.com/myformlibrary
  • 8/6/2019 Nintex Workflow 2007 SDK 1.1

    11/214

    Page 11 of 214www.nintex.com [email protected] connect.nintex.com

    2008 Nintex LLC, All rights reserved. Errors and omissions excepted.

    Software Development Kit v1.1

    Name Setup approval control

    Conditions Submitted = string(true()) AND

    SharePointTaskId != "" AND

    TaskType = "Approval"

    Actions 1. Set a field's value: AllowApproval = true()Field Fully

    Qualified

    References

    Submitted = /my:expenseReport/my:ExpenseForm/my:Submitted SharePointTaskId = GetRunningWorkflowTasksForCurrentUser

    /dfs:myFields/dfs:dataFields/

    tns:GetRunningWorkflowTasksForCurrentUserResponse/

    tns:GetRunningWorkflowTasksForCurrentUserResult/tns:UserTask/

    tns:SharePointTaskId

    TaskType = GetRunningWorkflowTasksForCurrentUser/dfs:myFields/dfs:dataFields/

    tns:GetRunningWorkflowTasksForCurrentUserResponse/

    tns:GetRunningWorkflowTasksForCurrentUserResult/tns:UserTask/tns:TaskType

    Figure: Screenshot from InfoPaths logic inspector

    Name Setup editing control

    Conditions Submitted = string(false()) OR

    Submitted = string(true()) AND

    SharePointTaskId != "" AND

    TaskType = "Approval"

    Actions 2. Set a field's value: AllowEditing = true()Field Fully

    Qualified

    References

    Submitted = /my:expenseReport/my:ExpenseForm/my:Submitted SharePointTaskId = GetRunningWorkflowTasksForCurrentUser

    /dfs:myFields/dfs:dataFields/

    tns:GetRunningWorkflowTasksForCurrentUserResponse/

    tns:GetRunningWorkflowTasksForCurrentUserResult/tns:UserTask/

    tns:SharePointTaskId

    TaskType = GetRunningWorkflowTasksForCurrentUser/dfs:myFields/dfs:dataFields/

    tns:GetRunningWorkflowTasksForCurrentUserResponse/

    tns:GetRunningWorkflowTasksForCurrentUserResult/tns:UserTask/tns:TaskType

    Figure: Screenshot from InfoPaths logic inspector

  • 8/6/2019 Nintex Workflow 2007 SDK 1.1

    12/214

    Page 12 of 214www.nintex.com [email protected] connect.nintex.com

    2008 Nintex LLC, All rights reserved. Errors and omissions excepted.

    Software Development Kit v1.1

    2. Configure the Approve button rulesa. Right click on the Approve button and click Propertiesb. Click on the Rules buttonc. Add the rules outlined below. Use the Field Name References row as a field fully qualified field reference.

    This will allow you to find the correct field in the Main data source.

    Name Set Approval SettingsConditions

    Actions 1. Set a field's value: spTaskId = SharePointTaskId2. Set a field's value: outcome = "Approved"3. Set a field's value: comments = Comments4. Query using a data connection: ProcessTaskResponse5. Close the form

    Field Fully

    Qualified

    References

    spTaskId = /dfs:myFields/dfs:queryFields/tns:ProcessTaskResponse/tns:spTaskId SharePointTaskId = GetRunningWorkflowTasksForCurrentUser

    /dfs:myFields/dfs:dataFields/

    tns:GetRunningWorkflowTasksForCurrentUserResponse/

    tns:GetRunningWorkflowTasksForCurrentUserResult/tns:UserTask/

    tns:SharePointTaskId outcome = /dfs:myFields/dfs:queryFields/tns:ProcessTaskResponse/tns:outcome comments = /dfs:myFields/dfs:queryFields/tns:ProcessTaskResponse/

    tns:comments

    Comments = /my:expenseReport/my:ExpenseForm/my:Comments

    Figure: Screenshot from InfoPaths logic inspector

    3. Configure the Reject button rules.a. Right click on the Reject button and click Propertiesb. Click on the Rules buttonc. Add the rules outlined below. Use the Field Name References row as a fully qualified field reference. This

    will allow you to find the correct field in the Main data source.

    Name Set Rejection Settings

    Conditions

    Actions 1. Set a field's value: spTaskId = SharePointTaskId2. Set a field's value: outcome = "Rejected"3. Set a field's value: comments = Comments4. Query using a data connection: ProcessTaskResponse5. Close the form

    Field Fully

    Qualified

    References

    spTaskId = /dfs:myFields/dfs:queryFields/tns:ProcessTaskResponse/tns:spTaskId SharePointTaskId = GetRunningWorkflowTasksForCurrentUser

    /dfs:myFields/dfs:dataFields/

    tns:GetRunningWorkflowTasksForCurrentUserResponse/

    tns:GetRunningWorkflowTasksForCurrentUserResult/tns:UserTask/

    tns:SharePointTaskId

    outcome = /dfs:myFields/dfs:queryFields/tns:ProcessTaskResponse/tns:outcome comments = /dfs:myFields/dfs:queryFields/tns:ProcessTaskResponse/

    tns:comments Comments = /my:expenseReport/my:ExpenseForm/my:Comments

  • 8/6/2019 Nintex Workflow 2007 SDK 1.1

    13/214

    Page 13 of 214www.nintex.com [email protected] connect.nintex.com

    2008 Nintex LLC, All rights reserved. Errors and omissions excepted.

    Software Development Kit v1.1

    Figure: Screenshot from InfoPaths logic inspector

    4. Configure the Submit button rules.a. Right click on the Submit button and click Propertiesb. Click on the Rules buttonc. Add the rules outlined below. Use the Field Name References row as a fully qualified field reference. This

    will allow you to find the correct field in the Main data source.

    Name Submit Expense

    Conditions

    Actions 1. Set a field's value: Submitted = true()2. Submit using a data connection: SharePoint Library Submit3. Close the form

    Field Fully

    Qualified

    References

    Submitted = /my:expenseReport/my:ExpenseForm/my:Submitted

    Figure: Screenshot from InfoPaths logic inspector

    5. Configure advanced form UIa. Now the business logic has been created we have a field called AllowEditing which was configured in rule

    Setup editing control. With this field we can configure the relevant form controls to allow editing or to

    display a read only view. Use this field and configure the input fields Conditional Formatting.

    b. Configure the Approval section to only display if the field AllowApproval is true.c. Configure the Submit section to only display if the field Submitted is false

  • 8/6/2019 Nintex Workflow 2007 SDK 1.1

    14/214

    Page 14 of 214www.nintex.com [email protected] connect.nintex.com

    2008 Nintex LLC, All rights reserved. Errors and omissions excepted.

    Software Development Kit v1.1

    Step 5Publish Form

    1. The form is ready to be published to the server.a. Click File -> Publishb. Select To a SharePoint server with or without InfoPath Forms Services, click Nextc.

    Enter inhttp://development.nintex.com, click Next

    d. Select Document Library as the publishing type, click Nexte. If you have not already created a library select Create a new document library, otherwise select Update

    the form template in an existing document library. For this example we assume a blank form library is

    already created called MyFormLibrary. Click Next

    f. We now need to promote key fields in the form to columns in the library, these are used by NintexWorkflow and InfoPath to share data. When adding each field ensure that the field can be editing from

    within SharePoint by selecting the option Allow users to edit data in this field by using a datasheet or

    properties page.

    i. Submittedii. Total

    iii. Expense Stateiv. File Url

    g. Click Next and the click Publish.

    http://development.nintex.com/http://development.nintex.com/http://development.nintex.com/http://development.nintex.com/
  • 8/6/2019 Nintex Workflow 2007 SDK 1.1

    15/214

    Page 15 of 214www.nintex.com [email protected] connect.nintex.com

    2008 Nintex LLC, All rights reserved. Errors and omissions excepted.

    Software Development Kit v1.1

    Step 6Create Workflow

    1. From the library where the form was created click Settings -> Create Workflow2. Create a new blank workflow3. Add a Wait for an item update action to the top of the workflow.

    a.

    Configure the action to wait for the field Submitted to equalyes.4. Add two Set field value actions to the workflow below the Wait for an item update action

    a. Configure the first Set field value action to update the field File URL and configure it to look up thecurrent list item and reference the Server Relative URL field.

    b. Configure the second Set field value action to update the Expense State field and configure it to a textvalue ofPending.

    5. Add a Request approval action. Configure the action to email yourself for testing purposes, however in aproduction form this could be set to the current users manager.

    6. On the Declined side of the Request approval action add a Set field value action and a Set approval status action.a. Configure the Set field value action to update the field Expense State and configure it to a text value of

    Rejected.

    b. Configure the Set approval status action to set the status to Denied.7. On the Approved side of the Request approval action add a Set field value action and a Set approval status action.

    a. Configure the Set field value action to update the field Expense State and configure it to a text value ofApproved.

    b. Configure the Set approval status action to set the status to Approved.8. Next we need to configure the workflow to start when the expense form is first created.

    a. Click Settings - > Startup optionsb. Select Start when items are created, click Save.

    9. Publish the workflow.a. Click Actions -> Publishb. Give the workflow a name and click Save.

    The completed workflow design

  • 8/6/2019 Nintex Workflow 2007 SDK 1.1

    16/214

    Page 16 of 214www.nintex.com [email protected] connect.nintex.com

    2008 Nintex LLC, All rights reserved. Errors and omissions excepted.

    Software Development Kit v1.1

    HOW TO: CREATE A CUSTOM WORKFLOW ACTION OVERVIEW

    SKILL LEVEL: ADVANCED

    OVERVIEW

    This section provides background information about how Nintex Workflow (NW) adds actions to a workflow. All

    actions in Nintex Workflow are Windows Workflows Foundation (WF) activities. To extend Nintex Workflow with

    your own WF activities you must complete the following:

    1. Create an Action Adapter that instructs NW how to handle the activity.2. Develop a Configuration Dialog (aspx) page that provides a user interface for workflow designers to configure the

    parameters for your action.

    3. Author an .nwa (NW Action) file that describes your activity, the adapter class and the UI dialog to load. This filewill be imported into NWs action list.

    REQUIREMENTS

    Windows SharePoint Services 3.0 Nintex Workflow 2007 Visual Studio

    SUMMARY

    1. Background Information2. Steps to Create an Action3. The Nintex Workflow 2007 Custom Action Visual Studio 2005 Project Template.4. Troubleshooting5. References

  • 8/6/2019 Nintex Workflow 2007 SDK 1.1

    17/214

    Page 17 of 214www.nintex.com [email protected] connect.nintex.com

    2008 Nintex LLC, All rights reserved. Errors and omissions excepted.

    Software Development Kit v1.1

    STEPS AND PROCEDURES

    Step 1 - Background Information

    Figure: Designing a workflow

    Figure: Publishing the Workflow

  • 8/6/2019 Nintex Workflow 2007 SDK 1.1

    18/214

    Page 18 of 214www.nintex.com [email protected] connect.nintex.com

    2008 Nintex LLC, All rights reserved. Errors and omissions excepted.

    Software Development Kit v1.1

    The list of available NW actions is stored in the NW configuration database. This database declares a relationship between a

    WF Activity, an NW Adapter and a designer UI.

    The adapter class must define methods to render the action in the UI and add an instance of the referenced WF activity to

    the parent workflow.

    The operations that are performed on an action for use in Nintex Workflow are as follows:

    1. When the Workflow Designer is loaded, the database is queried and each allowed action is listed in the toolbox.2. When an action is dragged on to the design canvas, the designer sends a request to the server detailing the action

    that was selected. The server then invokes the necessary adapter class to obtain the html to render the action.

    3. The rendered action has an attribute containing the default configuration xml along with the url of the aspx dialogused to configure the action. The configuration xml is a serialized instance of the

    Nintex.Workflow.Actions.Adapters.NWActionConfig class.

    4. When the action is configured, the dialog page is opened as a modal window. The dialog is responsible formodifying the configuration xml.

    5. When the dialog returns, the configuration xml is sent to the server. The adapter then validates the configurationand returns html. The returned html contains an attribute IsValid which is set by the adapter to indicate whether

    or not the action configuration is valid. The workflow will not publish while an action has an invalid configuration.

    6. When the workflow is published each actions configuration xml is sent to the server as a batch. For each actionthe corresponding adapter classs AddActivityToWorkflow method is invoked. Typically this method will

    instantiate an instance of the WF Activity it is responsible for, set the activity properties according to the

    configuration xml and add the activity to the parent workflow object. Once all adapters have been called the

    resulting workflow object is converted to WF Xoml and associated to a SharePoint list ready for use.

    7. When a workflow is rendered, NW reads from the workflows Xoml. For each activity it determines thecorresponding adapter and calls a render method (either runtime, design or preview) to return html. The

    NWActionConfiginstance is obtained by passing the Activity into the adapters GetConfig method where the

    properties of the Activity are read and an NWActionConfig object is constructed.

    Step 2 - Steps to Create an Action

    Prerequisites

    To write your own WF activity you will need the Visual Studio 2005 extensions for .NET Framework 3.0. See the Support

    Resources section.

    To use the Nintex Workflow 2007 custom action project, the Visual Studio Web Application project template must be

    installed. It is a part of Service Pack 1 for Visual Studio and also available as a standalone patch. Downloads and more

    information is available from here:http://msdn2.microsoft.com/en-us/asp.net/aa336618.aspx. See the Support Resources

    section for Service Pack 1 details.

    All actions in Nintex Workflow are Windows Workflow Foundation activities (System.Workflow.ComponentModel.Activity).

    Any WF activity can be imported into Nintex Workflow 2007. Activities are developed using Microsoft Visual Studio, and the

    appropriate documentation should be referred to regarding development.

    Creating the Adapter

    NW adapters must implement a number of Interfaces. These include:

    Nintex.Workflow.Activities.Adapters.IActivityAdapterThis interface contains members common for all adapters.

    http://msdn2.microsoft.com/en-us/asp.net/aa336618.aspxhttp://msdn2.microsoft.com/en-us/asp.net/aa336618.aspxhttp://msdn2.microsoft.com/en-us/asp.net/aa336618.aspxhttp://msdn2.microsoft.com/en-us/asp.net/aa336618.aspx
  • 8/6/2019 Nintex Workflow 2007 SDK 1.1

    19/214

  • 8/6/2019 Nintex Workflow 2007 SDK 1.1

    20/214

    Page 20 of 214www.nintex.com [email protected] connect.nintex.com

    2008 Nintex LLC, All rights reserved. Errors and omissions excepted.

    Software Development Kit v1.1

    ASP.Net

    For more information on the activity UI master page see the master page section in the SDK.

    Two JavaScript functions are required to retrieve and write configuration xml. These functions are called from the scripts

    included in the master page.

    function TPARetrieveConfig()This function must read the configuration xml and populate the controls in the dialog with the correct values.

    function TPAWriteConfig() This function must read values from the controls on the dialog and write them into the configuration xml. If you

    wish to perform input validation at this point you may do so and returning false from this function will prevent the

    dialog from closing, otherwise return true.

    These functions have access to a global XML Dom object called configXml. This object contains the configuration xml for the

    action. These functions read and write values to the xml stored in this object and the script referenced in the master page

    handles the creation and persistence of the configXml object.

  • 8/6/2019 Nintex Workflow 2007 SDK 1.1

    21/214

    Page 21 of 214www.nintex.com [email protected] connect.nintex.com

    2008 Nintex LLC, All rights reserved. Errors and omissions excepted.

    Software Development Kit v1.1

    Additional context data in the dialog

    The dialog is passed a querystring value called ListId which contains the Guid of the list that the workflow is being designed

    for.

    To get a list of workflow variables, call ListWorkflowVariables() in JavaScript. The result is an array of Xml Elements defining

    each workflow variable, its type and whether it is initialized on the start workflow page.

    See the Web Controls section of the SDK for information on controls that can be used to insert data references.

    Importing into Nintex Workflow

    The steps to import the custom action into Nintex Workflow are as follows:

    1. Ensure all assemblies are strongly named and deployed to the Global Assembly Cache (GAC) on each front end webserver.

    2. Open SharePoint Central Administration.3.

    Choose Application Management.

    4. Choose Manage Allowed Actions in the Nintex Workflow Management section.5. Click the Add Action link.6. Choose Import Workflow Action if you have a .nwa file from the Visual Studio project template and select the

    correct file or expand Show Details and fill in the required fields manually. After importing a .nwa file, the details

    can be verified by expanding Show Details.

    7. Select the web application to register this activity on.8. Click the Ok button. You will be redirected to the known action list.9. Select the checkbox next to the new action to enable it.10. 10. IISRESET

    The action will now appear in the designer. Note that the import process automatically creates a SafeAction element in the

    web.config. SharePoint requires workflow activities to be registered as safe before they can be used in declarative

    workflows.

  • 8/6/2019 Nintex Workflow 2007 SDK 1.1

    22/214

    Page 22 of 214www.nintex.com [email protected] connect.nintex.com

    2008 Nintex LLC, All rights reserved. Errors and omissions excepted.

    Software Development Kit v1.1

    Step 3 - The Nintex Workflow 2007 Custom Action Visual Studio 2005 Project Template

    Installed with this SDK is a project template for Visual Studio 2005 to assist with the development of custom actions.

    What the template includes

    The project template will create the following directory and file structure:

    \.csproj

    \.nwa

    \Dialog.aspx

    \Dialog.aspx.cs

    \ App_Code\Adapter.cs

    \ images\Activity.png

    \ images\ActivitySmall.png

    \ images\ActivityWarning.png

    \ properties\AssemblyInfo.cs

    This includes a base configuration dialog, WF activity class, adapter class, default icons for the action and a .nwa action

    import file.

    The.nwa file defines all the information required to import the new Nintex Workflow 2007 Action into SharePoint CentralAdministration. After building and signing the assembly, the activityAssembly and adapterAssembly elements must be

    populated.

    MyWorkflowAction, Version 1.0.0.0, Culture=neutral,

    PublicKeyToken=12345678901234567

  • 8/6/2019 Nintex Workflow 2007 SDK 1.1

    23/214

    Page 23 of 214www.nintex.com [email protected] connect.nintex.com

    2008 Nintex LLC, All rights reserved. Errors and omissions excepted.

    Software Development Kit v1.1

    Step 4Troubleshooting

    Debugging the action

    The adapter and activity code can be debugged in the SharePoint environment by installing a debug build and attaching a

    debugger to each w3wp.exe process.

    Nothing happens when the action is dragged onto the designer

    This symptom will occur when the designer cannot find the class to load. Check that all the assembly and class information

    for the activity and adapter is correct in the Manage Allowed Actions screen in Central Administration. This symptom will

    also occur if an exception is thrown when rendering the action. Attach a debugger to the GetDefaultConfig and

    ValidateConfig methods of the adapter to check if the code is throwing an exception. Also ensure that an IISRESET was

    performed since the action was enabled.

    The workflow status column shows Error Occurred

    This symptom will occur when the WF Activity code throws an exception. Attach a debugger to the activity code.

    Step 5References

    Configuration XML

    When reading the configXml in JavaScript, the xml will resemble the following example.

    Nintex Workflow Xml

    Workflow action name-1MyCompany.MyWorkflowActions, Version=1.0.0.0, Culture=neutral,PublicKeyToken=xxxxxxxxxxxxxMyCompany.MyWorkflowActions.MyAdaptertrueNone

  • 8/6/2019 Nintex Workflow 2007 SDK 1.1

    24/214

    Page 24 of 214www.nintex.com [email protected] connect.nintex.com

    2008 Nintex LLC, All rights reserved. Errors and omissions excepted.

    Software Development Kit v1.1

    Nintex Workflow Xml Node

    The first few nodes hold system data and configuration dialogs can ignore the values.

    The , , and elements hold the text is the top, bottom, left and right labels of the

    action. The attributes LCustLbl, RCustLbl, TCustLbl and BCustLbl specify whether the user has customized any label with the

    edit label dialog.

    The holds the total minutes value if the user has specified an expected duration.

    The and elements contain the reference to the adapter class for the action.

    The value tells the designer whether the action is completely configured. It is set automatically by the system

    based on result of the adapters ValidateConfig() method.

    The element is a system node related to conditions.

    The remaining nodes hold the configuration data. There are two sets of nodes: parameters and field references. Parameters

    hold explicit values and field references can be used for a dynamic list of values. There is no hard rule regarding when and

    how to use each.

    Remember that the default configuration is defined in the GetDefaultConfig adapter method. The following code in

    GetDefaultConfig would produce the corresponding Xml.

    C#

    NWActionConfig c = new NWActionConfig();c.Parameters = new ActivityParameter[1];c.Parameters[0] = new ActivityParameter();c.Parameters[0].Name = "x";

    c.Parameters[0].PrimitiveValue = new PrimitiveValue();c.Parameters[0].PrimitiveValue.Value = "Some Value";c.Parameters[0].PrimitiveValue.ValueType = SPFieldType.Text.ToString();

    Nintex Workflow Xml

    The child node ofParameter (and FieldReference) can be a PrimitiveValue or a Variable to represent a workflow variable.

    Using the correct value nodes allow for the use of helper methods in building the workflow to assist in automatically

    interpreting the configuration xml.

  • 8/6/2019 Nintex Workflow 2007 SDK 1.1

    25/214

    Page 25 of 214www.nintex.com [email protected] connect.nintex.com

    2008 Nintex LLC, All rights reserved. Errors and omissions excepted.

    Software Development Kit v1.1

    HOW TO: CREATE A CUSTOM WORKFLOW ACTION STEP BY STEP GUIDE

    SKILL LEVEL: ADVANCED

    OVERVIEW

    This example details the steps required to create a custom action for Nintex Workflow 2007 (NW). This example will use

    the example of a custom Windows Workflow Foundation (WF) activity that executes a SQL command against a database. It

    will detail how to write the WF activity, the NW adapter, a user interface and how to expose the action in the NW designer.

    The completed solution is included in this SDK.

    This example will make use of the Nintex Workflow Action Visual Studio project template. For more information on Visual

    Studio project templates seehttp://technet.microsoft.com/en-us/library/6db0hwky(VS.80).aspx.

    REQUIREMENTS

    Windows SharePoint Services 3.0 Nintex Workflow 2007 Visual Studio 2005 Extensions for the .NET Framework 3.0 Visual Studio 2005 Service Pack 1

    SUMMARY

    This is a quick summary of the steps and procedures required to complete this example.

    1. Building the Workflow Foundation activity2. Building the Nintex Workflow adapter3. Building the configuration dialog4. Importing into Nintex Workflow

    SUPPLIED SAMPLES

    This example contains the completed Visual Studio solution for the Nintex Workflow SQL action. Also as a part of this

    example Nintex Workflow has developed a custom Visual Studio 2005 project template to aid in the development process

    of actions for Nintex Workflow.

    To deploy the Nintex Workflow Action Visual Studio project template copy the supplied zip file to you Visual Studio Project

    Templates (Visual C#) folder. This location of this folder can be found in your Visual Studio preferences (Tools -> Options ->

    Project and Solutions -> Visual Studio user project template location).

    Solutions

    1. {SDK Location}\Examples\ExecuteSqlAction2. {SDK Location}\support\NW2007ActionProjectTemplate

    http://technet.microsoft.com/en-us/library/6db0hwky(VS.80).aspxhttp://technet.microsoft.com/en-us/library/6db0hwky(VS.80).aspxhttp://technet.microsoft.com/en-us/library/6db0hwky(VS.80).aspxhttp://technet.microsoft.com/en-us/library/6db0hwky(VS.80).aspx
  • 8/6/2019 Nintex Workflow 2007 SDK 1.1

    26/214

  • 8/6/2019 Nintex Workflow 2007 SDK 1.1

    27/214

    Page 27 of 214www.nintex.com [email protected] connect.nintex.com

    2008 Nintex LLC, All rights reserved. Errors and omissions excepted.

    Software Development Kit v1.1

    This activity will be written to be used in the context of SharePoint and Nintex Workflow. References must be

    added to:

    Microsoft.SharePoint.dll Microsoft.SharePoint.WorkflowActions.dll Nintex.Workflow.dll.The SharePoint assemblies are located by default in c:\program files\common files\microsoft shared\web

    server extensions\12\isapi. The Nintex Workflow assembly can be located from the GAC.

    Add additional using statements as shown in the following code snippet.

  • 8/6/2019 Nintex Workflow 2007 SDK 1.1

    28/214

    Page 28 of 214www.nintex.com [email protected] connect.nintex.com

    2008 Nintex LLC, All rights reserved. Errors and omissions excepted.

    Software Development Kit v1.1

    C#

    using System.Data;using System.Data.SqlClient;using System.Workflow.ComponetModel;using Microsoft.SharePoint.Workflow;

    using Microsoft.SharePoint.WorkflowActions;using Nintex.Workflow;

    namespace MyCompany.WorkflowActions{

    public partial class ExecuteSqlActivity: Activity{

    public ExecuteSqlActivity(){

    InitializeComponent();}

    }}

    4. Add Dependency Properties to the activity:Dependency Properties are object properties that can be bound to other elements of a workflow such as workflow

    variables. We use them to store the data that the activity will require or to output data from the activity. This

    activity will use seven Dependency Properties.

    ConnectionStringProperty and SqlQueryProperty store the configurable information for this activity. ResultOutputProperty will save any result into a workflow variable. __ListItemProperty, __ContextProperty and__ListIdProperty are properties included in most SharePoint

    activities. They provide context about the list and item that the workflow is running on.

    CurrentWorkflowVariableValuesProperty is used by Nintex Workflow to provide a Hashtable of workflowvariable names and values to the activity. The Dependency Properties are declared as members of the

    ExecuteSqlActivity class:

  • 8/6/2019 Nintex Workflow 2007 SDK 1.1

    29/214

    Page 29 of 214www.nintex.com [email protected] connect.nintex.com

    2008 Nintex LLC, All rights reserved. Errors and omissions excepted.

    Software Development Kit v1.1

    C#

    public static DependencyProperty CurrentWorkflowVariableValuesProperty =DependencyProperty.Register("CurrentWorkflowVariableValues",typeof(Hashtable), typeof(ExecuteSqlActivity));

    public static DependencyProperty __ListItemProperty =DependencyProperty.Register("__ListItem", typeof(int),typeof(ExecuteSqlActivity));

    public static DependencyProperty __ContextProperty =DependencyProperty.Register("__Context", typeof(WorkflowContext),typeof(ExecuteSqlActivity));

    public static DependencyProperty __ListIdProperty =DependencyProperty.Register("__ListId", typeof(string),typeof(ExecuteSqlActivity));

    public static DependencyProperty ConnectionStringProperty =

    DependencyProperty.Register("ConnectionString", typeof(string),typeof(ExecuteSqlActivity));

    public static DependencyProperty SqlQueryProperty =DependencyProperty.Register("SqlQuery", typeof(string),typeof(ExecuteSqlActivity));

    public static DependencyProperty ResultOutputProperty =DependencyProperty.Register("ResultOutput", typeof(string),typeof(ExecuteSqlActivity));

    Each dependency property must also be exposed as a public property; the following shows the property

    implementation of the__ContextProperty:

    C#

    [ValidationOption(ValidationOption.Required),Browsable(true),DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]public WorkflowContext __Context{

    get{return(WorkflowContext)base.GetValue(ExecuteSqlActivity.__ContextProperty);

    }set{

    base.SetValue(ExecuteSqlActivity.__ContextProperty, value);}

    }

    Repeat for each of the seven dependency properties.

  • 8/6/2019 Nintex Workflow 2007 SDK 1.1

    30/214

    Page 30 of 214www.nintex.com [email protected] connect.nintex.com

    2008 Nintex LLC, All rights reserved. Errors and omissions excepted.

    Software Development Kit v1.1

    5. Override the Execute method:The Execute method of the activity defines the runtime behavior. To implement, override as follows:

    C#

    protected override ActivityExecutionStatus Execute(ActivityExecutionContextexecutionContext){}

    The Execute method of this activity implements simple data access code:

    C#

    using(SqlConnection conn = new SqlConnection(ConnectionString))using(SqlCommand command = new SqlCommand()){

    command.Connection = conn;command.CommandType = CommandType.Text;command.CommandText = SqlQuery; conn.Open();object result = command.ExecuteScalar();

    if(result != null)this.ResultOutput = result.ToString();

    }

    return ActivityExecutionStatus.Closed;

    Note: The values are retrieved from the Dependency Properties by calling the implemented property. Also note theResultOutput is being assigned to. Any workflow variable that is bound to ResultOutput will now contain the value

    of result.

    6. Add a check that the action is allowed to run in workflows. This is a security measure that will cause the workflowto fail if the action is not allowed on the site the workflow is running on.

    C#

    ActivityActivationReference.IsAllowed(this.GetType(), __Context.Web);

    7. Add runtime context data:To provide more flexibility when configuring the SQL query, we want to enable lookups to context data. Context

    data consists of workflow variables, list item properties and other common data such as the user that initiated the

    workflow. In NW, lookups are done by using tags in a string. For example, {ItemProperty:Title} in a string is replaced

    at runtime with the title of the item that the workflow is running on. Formats for these references are:

    {ItemProperty:internalFieldName}

    properties of the item the workflow is acting on.

    {WorkflowVariable:variableName}

    workflow variables.

  • 8/6/2019 Nintex Workflow 2007 SDK 1.1

    31/214

    Page 31 of 214www.nintex.com [email protected] connect.nintex.com

    2008 Nintex LLC, All rights reserved. Errors and omissions excepted.

    Software Development Kit v1.1

    {Common:xxxx}

    predefined references. There is a list of common references is in the overview document.

    {WorkflowConstant:constantName}

    A workflow constant configured for the enviroment.

    The activity is responsible for replacing the reference tags with actual values. Reference replacement is done by

    constructing an NWContext object and calling the AddContextDataToString method as shown here.

    C#

    NWContext ctx = new NWContext(this.__Context,new Guid(this.__ListId),this.__ListItem,this.WorkflowInstanceId,

    CurrentWorkflowVariableValues,this);

    // Replace any inserted property references// (Common, ItemProperties and WorkflowVariables) with the current value.

    string sqlQuery = ctx.AddContextDataToString(SqlQuery, true);

    The NWContext object is constructed using context information from the workflow provided through the

    dependency properties. In this case the code is replacing any references in the SqlQuery property. The result from

    this method should then be passed in to command.CommandText.

    8. Handle exceptions:The final code in the activity is to handle any exceptions. This is done by overriding HandleFault.

    C#

    protected override ActivityExecutionStatusHandleFault(ActivityExecutionContext executionContext, Exceptionexception){}

    To handle any exception that is thrown during execution. The following code will log the exception message to the

    workflow history list.

    C#

    ISharePointService spService =(ISharePointService)executionContext.GetService(

    typeof(ISharePointService));

    spService.LogToHistoryList(this.WorkflowInstanceId,SPWorkflowHistoryEventType.WorkflowError,

    -1,

  • 8/6/2019 Nintex Workflow 2007 SDK 1.1

    32/214

    Page 32 of 214www.nintex.com [email protected] connect.nintex.com

    2008 Nintex LLC, All rights reserved. Errors and omissions excepted.

    Software Development Kit v1.1

    C#

    TimeSpan.MinValue,"Error",string.Format("Error performing database action. {0}",exception.Message),

    string.Empty);

    return base.HandleFault(executionContext, exception);

    9. Sign the assembly:Workflow activities used by NW must be installed into the Global Assembly Cache. Therefore the assembly must be

    strongly named. To sign the assembly: Right click on the project, choose Properties from the menu and select the

    Signing page. Choose Sign the assembly and create a new key.

    Step 2 - Building the Nintex Workflow adapter

    Nintex Workflow uses adapters to control how each WF Activity is rendered and configured.

    1. Create an adapter projectAdd a new Nintex Workflow 2007 Action project to the solution. The template is found under My Templates in the

    Visual C# category.

    The project template creates a number of files.

  • 8/6/2019 Nintex Workflow 2007 SDK 1.1

    33/214

    Page 33 of 214www.nintex.com [email protected] connect.nintex.com

    2008 Nintex LLC, All rights reserved. Errors and omissions excepted.

    Software Development Kit v1.1

  • 8/6/2019 Nintex Workflow 2007 SDK 1.1

    34/214

    Page 34 of 214www.nintex.com [email protected] connect.nintex.com

    2008 Nintex LLC, All rights reserved. Errors and omissions excepted.

    Software Development Kit v1.1

    You will need to add references to Microsoft.SharePoint.dll, Microsoft.SharePoint.WorkflowActions.dll,

    Nintex.Workflow.dll and a project reference to the activity created in the first section.

    The adapter inherits from Nintex.Workflow.Activities.Adapter.GenericRenderAdapter. Method stubs are created

    for the methods that must be overridden. The following explains how to implement each method.

    2. Override GetDefaultConfigC#

    public override NWActionConfig GetDefaultConfig(Guid listId){}

    This method defines the parameters that can be configured for this action. In this case, a parameter is needed for

    the Connection String, Sql Query and Result properties of the ExecuteSqlActivity class.

    3. Define global constant names for each propertyC#

    const string ConnectionStringProperty = "ConnectionString";const string SqlQueryProperty = "SqlQuery";const string OutputProperty = "Output";

    4. Create an ActivityParameter arrayAdd an ActivityParameter object for each parameter to the array in the NWActionConfig object.

    C#

    c.Parameters = new ActivityParameter[3];

    // Define the parameters that the user can configure for this actionc.Parameters[0] = new ActivityParameter();c.Parameters[0].Name = ConnectionStringProperty;c.Parameters[0].PrimitiveValue = new PrimitiveValue();c.Parameters[0].PrimitiveValue.Value = string.Empty;c.Parameters[0].PrimitiveValue.ValueType = SPFieldType.Text.ToString();

    c.Parameters[1] = new ActivityParameter();

    c.Parameters[1].Name = SqlQueryProperty;c.Parameters[1].PrimitiveValue = new PrimitiveValue();c.Parameters[1].PrimitiveValue.Value = string.Empty;c.Parameters[1].PrimitiveValue.ValueType = SPFieldType.Text.ToString();

    c.Parameters[2] = new ActivityParameter();c.Parameters[2].Name = OutputProperty;c.Parameters[2].Variable = new NWWorkflowVariable();

    Each ActivityParameter has a name and a value. The value can either be a Primitive Value or a WorkflowVariable,

    defined by setting the corresponding property. Primitive Values represent a user-typed value, as opposed to

    binding to a workflow variable.

  • 8/6/2019 Nintex Workflow 2007 SDK 1.1

    35/214

    Page 35 of 214www.nintex.com [email protected] connect.nintex.com

    2008 Nintex LLC, All rights reserved. Errors and omissions excepted.

    Software Development Kit v1.1

    5. Override ValidateConfigC#

    public override bool ValidateConfig(ActivityContext context){}

    This method defines when the configuration is in a state that the action can be published. The custom logic can

    check for anything; however there are some inbuilt methods for making sure the value entered is of the correct

    type.

    6. Add a dictionary ofActivityParameterHelpers to assist validationC#

    Dictionary parameters =

    context.Configuration.GetParameterHelpers();

    7. You can then validate that the connection string is not blank by checking it is a not an empty string value:C#

    if (!parameters [ConnectionStringProperty].Validate(typeof(string), context))

    {isValid &= false;validationSummary.AddError("Connection String",

    ValidationSummaryErrorType.CannotBeBlank);}

    The validationSummary member defines what is displayed in the mouse over popup for an invalid action. Each

    validation fault is added to the validationSummary to inform the user.

    8. Override AddActivityToWorkflowC#

    public override CompositeActivity AddActivityToWorkflow(NWActionConfigconfig,

    RootWorkflowActivityWithData parentWorkflow,CompositeActivity parentActivity,RuleConditionReference condition,WorkflowVariableCollection variables){}

    This method assigns the values from the configuration to a new instance of the activity that the adapter is

    responsible for

  • 8/6/2019 Nintex Workflow 2007 SDK 1.1

    36/214

    Page 36 of 214www.nintex.com [email protected] connect.nintex.com

    2008 Nintex LLC, All rights reserved. Errors and omissions excepted.

    Software Development Kit v1.1

    9. Create a new instance of the activity classC#

    ExecuteSqlActivity a = new ExecuteSqlActivity();

    10. Assign values from the configurationHere you can use a Dictionary ofActivityParameterHelpers to assist in assigning values. The AssignTo method

    wraps handling of details such as whether to bind a workflow variable or set a primitive value.

    C#

    Dictionary parameters =config.GetParameterHelpers();

    parameters[ConnectionStringProperty].AssignTo(a,ExecuteSqlActivity.ConnectionStringProperty, parentWorkflow,parentActivity, variables);

    parameters[SqlQueryProperty].AssignTo(a,ExecuteSqlActivity.SqlQueryProperty, parentWorkflow,parentActivity, variables);

    parameters[OutputProperty].AssignTo(a,ExecuteSqlActivity.ResultOutputProperty, parentWorkflow,parentActivity, variables);

    11. Set any additional propertiesIf the activity requires additional context data that isnt user defined, this must be bound manually. In this

    example, the ExecuteSqlActivity uses standard SharePoint context data.

    C#

    a.SetBinding(ExecuteSqlActivity.__ContextProperty, newActivityBind(parentWorkflow.Name,StandardWorkflowDataItems.__context));

    a.SetBinding(ExecuteSqlActivity.__ListItemProperty, newActivityBind(parentWorkflow.Name,StandardWorkflowDataItems.__item));

    a.SetBinding(ExecuteSqlActivity.__ListIdProperty, newActivityBind(parentWorkflow.Name,StandardWorkflowDataItems.__list));

  • 8/6/2019 Nintex Workflow 2007 SDK 1.1

    37/214

    Page 37 of 214www.nintex.com [email protected] connect.nintex.com

    2008 Nintex LLC, All rights reserved. Errors and omissions excepted.

    Software Development Kit v1.1

    The activity also uses a hashtable of variable names and values for use in the NWContext object. The following

    code hooks up this hashtable to the activity.

    C#

    ActivityBind currentVariablesHashtableBind =ActivityAdapterUtil.AddAllVariableNames(parentWorkflow);

    a.SetBinding(ExecuteSqlActivity.CurrentWorkflowVariableValuesProperty,currentVariablesHashtableBind);

    12. Persist labels and expected duration to the activityThese properties are common to all activities and are stored in a seralized ActivityFlagsobject in the activitys

    description property. Description is a member of the base activity class so there are no special requirements to the

    store this data.

    C#

    ActivityFlags f = new ActivityFlags();f.AddLabelsFromConfig(config);f.AssignTo(a);

    13. Add the activity to its parent and return.Remember to add the activity to the parentActivity not the parentWorkflow. This ensures that the ordering of

    activities is correct.

    C#

    parentActivity.Activities.Add(a);

    return null;

    14. Override GetConfigC#

    public override NWActionConfig GetConfig(Activity a,List supportingActivities, Hashtable ruleConfigs,Guid listId, WorkflowVariableCollection variables){}

    This method populates an NWActionConfig object from an existing activity object. It involves reading the

    properties of an activity and storing the values in the configuration object.

  • 8/6/2019 Nintex Workflow 2007 SDK 1.1

    38/214

    Page 38 of 214www.nintex.com [email protected] connect.nintex.com

    2008 Nintex LLC, All rights reserved. Errors and omissions excepted.

    Software Development Kit v1.1

    15. Construct a new instance ofNWActionConfig.C#

    NWActionConfig c = this.GetDefaultConfig(listId);

    16. Retrieve the values from the activity.A dictionary ofActivityParameterHelpers assists when working with Dependency Properties:

    C#

    Dictionary parameters =c.GetParameterHelpers();

    parameters[ConnectionStringProperty].RetrieveValue(a,

    ExecuteSqlActivity.ConnectionStringProperty, listId, variables);

    parameters[SqlQueryProperty].RetrieveValue(a,ExecuteSqlActivity.SqlQueryProperty, listId, variables);

    parameters[OutputProperty].RetrieveValue(a,ExecuteSqlActivity.ResultOutputProperty, listId, variables);

    17. Retrieve the labels for the UI.C#

    ActivityFlags f = ActivityFlags.GetFlags(a);c.SetLabels(f);

    18. Update the IsValid flag to reflect the retrieved configuration.C#

    c.IsValid = ValidateConfig(new ActivityContext(listId,ActivityReferenceCollection.FindByAdapter(this), c));

    19. Override BuildSummaryC#

    public override ActionSummary BuildSummary(ActivityContext context)

    This method defines what is visible in the mouse over popup summary of the action. It should provide a brief

    summary of what the action will do. The ActionSummary takes a string that will be rendered. This example

    includes the connection string value to provide some contextual information.

  • 8/6/2019 Nintex Workflow 2007 SDK 1.1

    39/214

    Page 39 of 214www.nintex.com [email protected] connect.nintex.com

    2008 Nintex LLC, All rights reserved. Errors and omissions excepted.

    Software Development Kit v1.1

    C#

    Dictionary parameters =context.Configuration.GetParameterHelpers();

    return new ActionSummary(string.Format("Run an SQL command on database

    {0}.", parameters[ConnectionStringProperty].Value));

    Step 3- Building the configuration dialog

    The configuration dialog contains JavaScript to manipulate the configuration xml, which is an xml serialized form of the

    NWActionConfig object generated in the adapter. The template aspx form in the project already includes references to the

    Nintex Workflow dialog master page which references required script files.

    1. Set the inherits property of the web form.As this assembly will be deployed to the GAC, the pages assembly reference must reference the strong name of

    the assembly. In the markup view, add the full assembly reference to the Inherits declaration.

    2. Design the web form.Add html controls that will allow users to enter values for each parameter. You can ensure consistent styling by

    using the styles included in the master page. The following html provides a text control for the sql connection

    string, a textarea for the sql query and a select list to choose a variable to store the activity output in.

    ASP.Net

    Connection String

    SQL Query

    SQL Query

    3. Add script to populate the dialog.JavaScript is used to read and write to and from the configuration xml to the input controls. The xml is stored in a

    global object call configXml. TPARetrieveConfig reads values from configXml into the input controls.

    TPAWriteConfig takes values from the input controls and stores them in configXml. External script that is included

    in the master page initially populates configXml and persists it when the dialog is saved.

    Declare global variables for the objects:

  • 8/6/2019 Nintex Workflow 2007 SDK 1.1

    40/214

    Page 40 of 214www.nintex.com [email protected] connect.nintex.com

    2008 Nintex LLC, All rights reserved. Errors and omissions excepted.

    Software Development Kit v1.1

    JavaScript

    var connectionStringCtrl;var sqlQueryCtrl;var resultOuputCtrl;

  • 8/6/2019 Nintex Workflow 2007 SDK 1.1

    41/214

    Page 41 of 214www.nintex.com [email protected] connect.nintex.com

    2008 Nintex LLC, All rights reserved. Errors and omissions excepted.

    Software Development Kit v1.1

    TPARetrieveConfig runs when the dialog opens, so add code to first set the control variables:

    JavaScript

    connectionStringCtrl = document.getElementById("connectionString");sqlQueryCtrl = document.getElementById("sqlQuery");resultOuputCtrl = document.getElementById("resultOutput");

    To allow the user to select from the list of variables that are defined, the resultOutputCtrl selection box must be

    populated with available choices. The JavaScript function ListWorkflowVariables will retrieve an xml node list of

    the variables that have been defined. In this case, we will filter the list to only show text variables.

    JavaScript

    var workflowVariables = ListWorkflowVariables();

    for(var i=0; i

  • 8/6/2019 Nintex Workflow 2007 SDK 1.1

    42/214

    Page 42 of 214www.nintex.com [email protected] connect.nintex.com

    2008 Nintex LLC, All rights reserved. Errors and omissions excepted.

    Software Development Kit v1.1

    JavaScript

    function TPAWriteConfig(){

    configXml.selectSingleNode("/NWActionConfig/Parameters/Parameter[@Name='ConnectionString']/PrimitiveValue/@Value").text =

    connectionStringCtrl.value;

    configXml.selectSingleNode("/NWActionConfig/Parameters/Parameter[@Name='SqlQuery']/PrimitiveValue/@Value").text = sqlQueryCtrl.value;

    if(resultOuputCtrl.selectedIndex > -1){configXml.selectSingleNode("/NWActionConfig/Parameters/Parameter

    [@Name='Output']/Variable/@Name").text =resultOuputCtrl.options[resultOuputCtrl.selectedIndex].value;}

    return true;}

    Step 4 - Importing into Nintex Workflow

    The following steps import the action into NW.

    1. Complete the NWA import file.The project includes a .nwa file for importing actions into Nintex Workflow. This file contains xml defining the

    information that NW requires to install the action. You will need to update the name, category, description and

    full assembly and type names for the adapter and activity.

    2. Deploy the action filesBoth the activity and adapter assemblies must be deployed to the GAC.

    The dialog page and icons must be placed in the CustomActions folder in the Nintex Workflow layouts folder in

    SharePoint.

    If the CustomActionsfolder doesnt exist, create it.

  • 8/6/2019 Nintex Workflow 2007 SDK 1.1

    43/214

  • 8/6/2019 Nintex Workflow 2007 SDK 1.1

    44/214

    Page 44 of 214www.nintex.com [email protected] connect.nintex.com

    2008 Nintex LLC, All rights reserved. Errors and omissions excepted.

    Software Development Kit v1.1

    HOW TO: CREATE A CUSTOM TASK RESPONSE FORM

    SKILL LEVEL: ADVANCED

    OVERVIEW

    This document describes how to use a custom task response form for the Request Approval or Request Review actions.

    Tasks assigned via these workflow actions are created with a specific content type that is installed when Nintex Workflow is

    activated. This content type has a custom edit form that is displayed when a user responds to a task. For more information

    about content types, see MSDN article Introduction to Content Types (http://msdn2.microsoft.com/en-

    us/library/ms472236.aspx).

    The approval and review actions can be configured to use a different content type. A custom approval form can be assigned

    to this content type.

    REQUIREMENTS

    This example requires the following technologies and/or applications:

    Windows SharePoint Services 3.0 Nintex Workflow 2007

    SUMMARY

    This is a quick summary of the steps and procedures required to complete this example.

    1. Create a custom Content Type2. Create a custom form3. Deploy the custom form4. Update content type to use the custom form5. Configure the workflow

    RESOURCES

    There is an example Visual Studio project in the Examples\CustomTaskForm folder. This contains a completed task form

    with the same look and feel as the out of the box task response form. It can be used as a basis for modifications.

    http://msdn2.microsoft.com/en-us/library/ms472236.aspxhttp://msdn2.microsoft.com/en-us/library/ms472236.aspxhttp://msdn2.microsoft.com/en-us/library/ms472236.aspxhttp://msdn2.microsoft.com/en-us/library/ms472236.aspxhttp://msdn2.microsoft.com/en-us/library/ms472236.aspxhttp://msdn2.microsoft.com/en-us/library/ms472236.aspx
  • 8/6/2019 Nintex Workflow 2007 SDK 1.1

    45/214

    Page 45 of 214www.nintex.com [email protected] connect.nintex.com

    2008 Nintex LLC, All rights reserved. Errors and omissions excepted.

    Software Development Kit v1.1

    STEPS AND PROCEDURES

    Procedure 1Create a custom Content Type

    Content types can be created through the SharePoint user interface. When creating a custom content type, an existing

    content type can be chosen as a base. In this case, the Nintex Workflow Task content type must be used.

    To create a content type, follow these steps:

    1. Open the Site Settings page of the team site that will contain the workflow.2. Open the Site content types page under the Galleries section.

    3. Select the "Create button at the top of the existing content types list.4. Enter a name and description of the content type.5. Under Parent Content Type, select Nintex Workflow for the group and Nintex Workflow Task for the parent

    content type.

    6. Press Ok to complete creating the content type.

  • 8/6/2019 Nintex Workflow 2007 SDK 1.1

    46/214

    Page 46 of 214www.nintex.com [email protected] connect.nintex.com

    2008 Nintex LLC, All rights reserved. Errors and omissions excepted.

    Software Development Kit v1.1

    Procedure 2Create a custom form

    1. Basic task approvalTo respond to a task and continue the workflow, the page code must open the task item and set certain values to

    signify that the task has been completed.

    The edit form for a task is provided with the following query string information:

    List The GUID of the task list

    ID The integer item ID of the task

    Source The URL that the user has come from. May not exist.

    This information is used to open the task item, as shown in the following code:

    C#

    int spTaskItemID = int.Parse(Page.Request.QueryString["ID"]);Guid taskListId = new Guid(Page.Request.QueryString["List"]);SPListCollection lists = SPContext.Current.Web.Lists;

    lists.ListsForCurrentUser = true;SPList taskList = lists.GetList(taskListId, false);SPListItem spTask = taskList.GetItemById(spTaskItemID);

    To respond to a task, set the decision and comments fields. These fields are a part of the base Nintex workflow task

    content type:

    C#

    int decision = 0;string comments = "";

    Guid commentsFieldId = newGuid("{819E6CF2-36C3-4013-8AEF-C99712C26036}");

    Guid decisionFieldId = newGuid("{A7AE99D0-E5DF-47f4-9D75-560E3F608006}");

    spTask[decisionFieldId] = decision;spTask[commentsFieldId] = comments;spTask.Update();

    If you have a reference to Nintex.Workflow.dll, the field id GUIDs are defined in constants found at:

  • 8/6/2019 Nintex Workflow 2007 SDK 1.1

    47/214

    Page 47 of 214www.nintex.com [email protected] connect.nintex.com

    2008 Nintex LLC, All rights reserved. Errors and omissions excepted.

    Software Development Kit v1.1

    C#

    Nintex.Workflow.Common.NWSharePointObjects.FieldCommentsNintex.Workflow.Common.NWSharePointObjects.FieldDecision

    The valid values for the decision are:

    Outcome Value

    Approved 0

    Rejected 1

    Continue (for review tasks) 5

    These are defined in the enumeration Nintex.Workflow.HumanApproval.Outcome

    2. The NintexTask classFurther functionality can be gained by adding reference to the assembly Nintex.Workflow.dll. The class

    Nintex.Workflow.HumanApproval.NintexTask stores information about the approval or review task of which the

    actual SharePoint task item is a part.

    The following code retrieves the NintexTask object that corresponds to the SharePoint task item.

    C#

    NintexTask task = NintexTask.RetrieveTask(spTaskItemID,SPContext.Current.Web, taskList);

    The task can either be an ApprovalTask or a ReviewTask object which both inherit from NintexTask. These objects

    contain information about the workflow, the item that the workflow is running on and all the users that have been

    designated as approvers/reviewers.

    3. The ItemProperties server controlThe Nintex.Workflow.ServerControls.dll contains an ItemProperties server control. This server control renders all

    the properties of the workflow item, respecting the View specified in Central Administration. With an

    ItemProperties control on the aspx page, it can be set up with the following code:

    C#

    SPList list = lists.GetList(task.WFContext.ListID);SPListItem item = list.GetItemById(task.WFContext.ItemID)

    itemProperties.Item = item;itemProperties.InstanceID = task.WFContext.InstanceID;

  • 8/6/2019 Nintex Workflow 2007 SDK 1.1

    48/214

    Page 48 of 214www.nintex.com [email protected] connect.nintex.com

    2008 Nintex LLC, All rights reserved. Errors and omissions excepted.

    Software Development Kit v1.1

    Procedure 3Deploy the custom form

    Custom aspx web forms are deployed to C:\Program Files\Common Files\Microsoft Shared\Web Server

    Extensions\12\TEMPLATE\LAYOUTS. A subfolder should be created in the layouts directory for any custom web forms.

    The compiled assembly should be deployed into the Global Assembly Cache. Repeat this on every front end server.

    Alternatively, create a SharePoint solution to manage the deployment and retraction of the custom development. See

    Solution Overview at MSDN for more informationhttp://msdn2.microsoft.com/en-us/library/aa543214.aspx.

    Procedure 4Update content type to use the custom form

    SharePoint provides no user interface for updating the form of a content type. It must be done through code. The code to

    update the edit form of a content type is as follows:

    C#

    using(SPSite s = new SPSite(teamsite))using (SPWeb web = s.OpenWeb()){

    SPContentTypeCollection contentTypes = web.ContentTypes;SPContentType ct = contentTypes[contenttypename];ct.EditFormUrl = formurl;ct.Update();

    }

    Note that if you do this in a HTTP request, you must set web.AllowUnsafeUpdates to true.

    Alternatively, Nintex Workflow 2007 ships with a command line administration application called nwadmin.exe, which

    supports setting the edit form for a content type. nwadmin.exe is located in the Nintex Workflow installation directory, by

    default this is [ProgramFiles]\Nintex\Nintex Workflow 2007.

    The command arguments:

    nwadmin.exe -o SetTaskForm

    -siteUrl

    -contentType

    -taskformUrl

    [-formType Edit|View|All] [-updateChildren Yes|No]

  • 8/6/2019 Nintex Workflow 2007 SDK 1.1

    49/214

    Page 49 of 214www.nintex.com [email protected] connect.nintex.com

    2008 Nintex LLC, All rights reserved. Errors and omissions excepted.

    Software Development Kit v1.1

    Procedure 5Configure the workflow

    In the workflow designer, drag on a Request Approval or Request Review action and configure it. If additional usable

    content types are detected, a drop down list will be displayed allowing you to select the custom content type.

    When the workflow is published, the content type will automatically be added to the task list used in the workflow.

  • 8/6/2019 Nintex Workflow 2007 SDK 1.1

    50/214

  • 8/6/2019 Nintex Workflow 2007 SDK 1.1

    51/214

    Page 51 of 214www.nintex.com [email protected] connect.nintex.com

    2008 Nintex LLC, All rights reserved. Errors and omissions excepted.

    Software Development Kit v1.1

    Procedure 2Build Workflow

    1. Create a new team site and enable Nintex Workflow.2. Navigate to the Shared Documents library.3. From the Settings link on the toobal click Create a Column.4. Type History in the Column name field.5. Select Multiple lines of text as the type of column.6. Select Allow unlimited length in document libraries.7. Click OK.8. From the Settings link on the toolbar click Create Workflow.9. In the workflow designer add a Log in the history list action to the blank workflow.10. Configure the action and enter This is a Nintex Workflow SDK example, then click Save.11. Next add a Delay for action under.12. Configure the action and enter 1 into the minute field, then click OK.13. From the toolbar click Settings -> Workflow Variables.14. Type workflowHistory in the Name field.15. Select Text as the variable type, and click Create and then Save.

    Figure: Workflow varibable workflowHistory.

    16. Add a Call web service action (in the integration category).17. Configure the call web service action:

    a. Set the URL to {Common:WebUrl}/_vti_bin/nintexworkflow/workflow.asmx,b. Set the credentials.c. Click the refresh button next to the web method and you will be prompted to confirm the url. Once

    confirmed, this will contact the web service and retrieve all the available methods.

    d. Select GetWorkflowHistory as the web method.

  • 8/6/2019 Nintex Workflow 2007 SDK 1.1

    52/214

    Page 52 of 214www.nintex.com [email protected] connect.nintex.com

    2008 Nintex LLC, All rights reserved. Errors and omissions excepted.

    Software Development Kit v1.1

    e. Click Edit SOAP and populate the parameters, for an easy example you can use the following values tocollect the current workflow history

    i. fileUrl = {Common:ItemUrl}ii. stateFilter = Running

    iii. workflowNameFilter = {Common:WorkflowTitle}Nintex Workflow Web Service SOAP

    {Common:ItemUrl}Running{Common:WorkflowTitle}

    f. Click XSL Transform and enter in you XSL code (see supporting files)g. Store the results in the workflow variable workflowHistory.h. Set the results format field to Xml.i. Save the configuration.

    Figure: Call Web Service configuration settings.

  • 8/6/2019 Nintex Workflow 2007 SDK 1.1

    53/214

    Page 53 of 214www.nintex.com [email protected] connect.nintex.com

    2008 Nintex LLC, All rights reserved. Errors and omissions excepted.

    Software Development Kit v1.1

    18. Add an Update an item action below the web service action19. Configure the update an item and set the Update field to Current item20. On the field History click the green arrow button to field a lookup value. In the pop up window set the Source

    field to Workflow Data, set the Workflow variable field to workflowHistory, click OK then click Save.

    Figure: Update an item workflow action settings.

    21. From the toolbar click Actions -> Publish.22. Enter Nintex Workflow SDK Export Example as the workflow name and click Save.

    Figure: The constructed workflow.

    To test the workflow:

    1. Navigate back to the Shared Documents library.2. Create a new document and save it into the library.3. From the new document's context menu select Workflows.4. On the Workflows page click Nintex Workflow SDK Export Example, and then click Start.

  • 8/6/2019 Nintex Workflow 2007 SDK 1.1

    54/214

    Page 54 of 214www.nintex.com [email protected] connect.nintex.com

    2008 Nintex LLC, All rights reserved. Errors and omissions excepted.

    Software Development Kit v1.1

    5. Once the workflow is completed you will see that the History field has been updated.

    Figure: Library view of output from the Nintex Workflow SDK Export Example workflow.

    Tip: The web service method GetWorkflowHistory requires a SPWorkflowState enumeration value. Below is a list of

    valid values. You can also find this information when viewing WSDL for the method (for example

    {weburl}/_vti_bin/nintexworkflow/workflow.asmx?op=GetWorkflowHistory)

    Tip: this example has been configured to work against a library, if you wished to collect the workflow history for a listitem you need to change the web service methods to GetWorkflowHistoryForListItem, which instead of a file Url it

    requires a item Id and list name. GetWorkflowHistoryForListItem can also be used with a document library to access a

    file by its ID.

    Tip: To view the raw information returned from the web service clear the web service call action XSL Transform field,

    this will then store the raw XML into the workflow variable.

    SPWorkflowState Values

    Running Completed Cancelled Faulting Terminated All

  • 8/6/2019 Nintex Workflow 2007 SDK 1.1

    55/214

    Page 55 of 214www.nintex.com [email protected] connect.nintex.com

    2008 Nintex LLC, All rights reserved. Errors and omissions excepted.

    Software Development Kit v1.1

    HOW TO: NINTEX WORKFLOW INTEGRATION WITH MICROSOFT BIZTALK SERVER 2006

    SKILL LEVEL: INTERMEDIATE/ADVANCED

    OVERVIEW

    Nintex Workflow Enterprise edition includes a Send / Receive BizTalk action for sending messages into BizTalk and / or

    waiting to receive a message from BizTalk. The action communicates to BizTalk using out of the box BizTalk adapters. The

    configuration of the workflow action generates the xsd schema files that match the message format that Nintex Workflow

    expects so they can easily be imported as BizTalk ports.

    In this scenario, a workflow is configured to send the username of the person who starts the workflow to BizTalk which

    communicates with a HR system to return the number of hours of leave the person has remaining. The workflow can then

    use this value elsewhere.

    REQUIREMENTS

    This example requires the following technologies and/or applications:

    Windows SharePoint Services 3.0 Nintex Workflow 2007 BizTalk Server 2006 Visual Studio 2005 (with BizTalk templates)

    SUMMARY

    This is a quick summary of the steps and procedures required to complete this example.

    1. Preparing Nintex Workflow2. Create the Orchestration3. Publish the Orchestration web service4. Configure the application in BizTalk Server Administration5. Complete the workflow configuration

  • 8/6/2019 Nintex Workflow 2007 SDK 1.1

    56/214

    Page 56 of 214www.nintex.com [email protected] connect.nintex.com

    2008 Nintex LLC, All rights reserved. Errors and omissions excepted.

    Software Development Kit v1.1

    STEPS AND PROCEDURES

    Procedure 1Preparing Nintex Workflow

    1. Create a workflow variable.This workflow variable will hold the value that is returned from BizTalk.

    2. Add a Send Receive BizTalk action.The Send / Receive BizTalk action is available in the Integration panel.

  • 8/6/2019 Nintex Workflow 2007 SDK 1.1

    57/214

    Page 57 of 214www.nintex.com [email protected] connect.nintex.com

    2008 Nintex LLC, All rights reserved. Errors and omissions excepted.

    Software Development Kit v1.1

    3. Define the data to for this action.Configure the Send / Receive BizTalk action.

    The panels labeled Data to Send and Data to Receive define the workflow data items that will make up the

    message to BizTalk and that will store the message that is received from BizTalk.

    Any data can be sent to BizTalk.

    Only workflow variables can store data that is received from BizTalk.

    Step 4:

    4. Export the message schemas.Nintex workflow automatically generates xsd files to represent the data that has been selected to send and

    receive. The xsd will consist of an xml node for each data item.

    Choose both Export XSD links to download the schema for the send message and the receive message.

  • 8/6/2019 Nintex Workflow 2007 SDK 1.1

    58/214

    Page 58 of 214www.nintex.com [email protected] connect.nintex.com

    2008 Nintex LLC, All rights reserved. Errors and omissions excepted.

    Software Development Kit v1.1

    At this point you can save the action and the workflow. We will finish configuring the action after we have

    configured BizTalk.

    Procedure 2Create the Orchestration

    1. Create a new BizTalk project in Visual Studio.

    2. Add the schema files that were exported from Nintex Workflow to the project.

  • 8/6/2019 Nintex Workflow 2007 SDK 1.1

    59/214

    Page 59 of 214www.nintex.com [email protected] connect.nintex.com

    2008 Nintex LLC, All rights reserved. Errors and omissions excepted.

    Software Development Kit v1.1

    3. Add an Orchestration.

    4.

    Add a receive port.This is the receive port that Nintex Workflow will send messages in to. Right click on the receive port surface and

    choose New Configured Port to start the Add port wizard.

    When asked, specify Public No Limit as the access restriction. Later, we will publish this Orchestration as a Web

    Service, and only public ports can be exposed.

  • 8/6/2019 Nintex Workflow 2007 SDK 1.1

    60/214

    Page 60 of 214www.nintex.com [email protected] connect.nintex.com

    2008 Nintex LLC, All rights reserved. Errors and omissions excepted.

    Software Development Kit v1.1

    5. Add a send port.Follow the create port wizard to configure a send port.

    6. Define messagesUse the schemas to create message instances, and bind the messages to the port operations.

    Reminder that the schema files are named from the perspective of Nintex Workflow, that is SendMessage.xsd

    represents a message being sent from Nintex workflow to BizTalk and ReceiveMessage.xsd represents the

    response from BizTalk to Nintex Workflow.

    Your orchestration should include all the elements shown in the following image. Input is a message created

    from SendMessage.xsd and Output is a message created from ReceiveMessage.xsd. The operations on the ports

    are bound to the appropriate message.

  • 8/6/2019 Nintex Workflow 2007 SDK 1.1

    61/214

    Page 61 of 214www.nintex.com [email protected] connect.nintex.com

    2008 Nintex LLC, All rights reserved. Errors and omissions excepted.

    Software Development Kit v1.1

    7. Define Orchestration.Define the elements that make up the flow of your orchestration. Refer to the BizTalk Server 2006 documentation

    for more information on designing orchestrations.

    The requirement for Nintex Workflow is that the 'LocationId' andMessageId elements in the header of both the

    send and receive message are bound to each other. Nintex Workflow uses these identifiers to determine whichworkflow a message is intended for.

    You will also need an active receive message action and a send message action to be hooked up to the ports. The

    message content data that is required in your orchestration must be promoted.

  • 8/6/2019 Nintex Workflow 2007 SDK 1.1

    62/214

    Page 62 of 214www.nintex.com [email protected] connect.nintex.com

    2008 Nintex LLC, All rights reserved. Errors and omissions excepted.

    Software Development Kit v1.1

    8. Deploy the application.Sign the application assembly, define a name for the application and deploy it to your BizTalk server.

    Procedure 3Publish the Orchestration web service

    1. Star the BizTalk Web Services Publishing Wizard.

    Note: the web services publishing wizard is only available on machines that have Visual Studio installed.

  • 8/6/2019 Nintex Workflow 2007 SDK 1.1

    63/214

  • 8/6/2019 Nintex Workflow 2007 SDK 1.1

    64/214

    Page 64 of 214www.nintex.com [email protected] connect.nintex.com

    2008 Nintex LLC, All rights reserved. Errors and omissions excepted.

    Software Development Kit v1.1

    Enter a namespace for the web service. This information will be used later when configuring the Nintex Workflow

    action.

    Enter the URL where the web service will be created. This information will be used later when configuring the

    Nintex Workflow action.

    You can specify your application for the publishing wizard to automatically generate the physical ports and

    locations to correspond to this web service.

  • 8/6/2019 Nintex Workflow 2007 SDK 1.1

    65/214

    Page 65 of 214www.nintex.com [email protected] connect.nintex.com

    2008 Nintex LLC, All rights reserved. Errors and omissions excepted.

    Software Development Kit v1.1

    Procedure 4Configure the application in BizTalk Server Administration

    1. Finish configuring the web service receive location.In the Receive Locations view, the generate location will be listed. If you already had the application open, you may

    need to refresh it.

    Configure the properties of the location and change the Receive Pipeline drop down to XMLReceive. This is

    required for the BizTalk engine to be able to read the xml to determine what time of message it has received.

    Enable the port.

    2. Configure a send port.Nintex Workflow exposes a http handler to receive messages from BizTalk as post data.

    Create a new send port and specify HTTP as its type.

  • 8/6/2019 Nintex Workflow 2007 SDK 1.1

    66/214

    Page 66 of 214www.nintex.com [email protected] connect.nintex.com

    2008 Nintex LLC, All rights reserved. Errors and omissions excepted.

    Software Development Kit v1.1

    Choose the Configure button to set the properties of the port. The url should be http:///_layouts/nintexworkflow/BiztalkHandler.ashx. Note that this url will handle workflows across the entire

    farm. Site context in the url is not required. Enter proxy and authentication as required for your environment.

    Enable the send port.

    3. Bind ports to the orchestration.Select the orchestration from the orchestrations section

    Set the correct host and the physical ports that have been defined in this section for the orchestrations logical

    ports.

    4. Start the Orchestration.

  • 8/6/2019 Nintex Workflow 2007 SDK 1.1

    67/214

    Page 67 of 214www.nintex.com [email protected] connect.nintex.com

    2008 Nintex LLC, All rights reserved. Errors and omissions excepted.

    Software Development Kit v1.1

    Procedure 5Complete the workflow configuration

    1. Configure the Send / Receive BizTalk actionOpen the saved workflow in Nintex Workflow 2007 and open the configuration screen for the Send/Receive BizTalk

    action.

    In the BizTalk Web Service Endpoint Settings panel enter the details of the web service that was published in

    step 3.

    Save the action.

    2. Use the data.The variable created to hold the data will be populated after the BizTalk action has been completed and can be

    used in the same way as any other piece of workflow data. For example, if can be used in the body of an email.

  • 8/6/2019 Nintex Workflow 2007 SDK 1.1

    68/214

  • 8/6/2019 Nintex Workflow 2007 SDK 1.1

    69/214

  • 8/6/2019 Nintex Workflow 2007 SDK 1.1

    70/214

    Page 70 of 214www.nintex.com [email protected] connect.nintex.com

    2008 Nintex LLC, All rights reserved. Errors and omissions excepted.

    Software Development Kit v1.1

    This method requires coding