20
Feb
08

BlackPearl Web Forms Workflow..

K2 (www.k2.com) is one of the pioneer companies in developing business process management (BPM) solutions. Microsoft products are by heart the foundation of K2 workflow platform. Including .NET 3.0, WWF, WPF, and MOSS 2007. Here, I will demonstrate a very basic walkthrough scenario on using K2BP workflow engine through ASPX pages.

The Scenario

Our walkthough scenario is an approval request for a general message generated by an employee. The employee will submit the form and the manager will either approve or reject it. Finally, the originator “employee” will get a copy of the submitted form.

The Solution

First, we need to build a new empty project from VS2005 File->New. Let’s name it “BasicApproval

Create New Project

From the Solution Explorer, add a new process from the New Item context menu.

Add K2 Process

Choose “process” and name it “BasicApprovalProcess.kprx“. Now, Let’s build and design our form that will represent the BasicApproval wrokflow. Basically, we will need three forms to fulfill the process requirements.

  1. BasicRequest.aspx: The first form that will initiate the process and the employee will create a new process instance from it.
  2. BasicApproval.aspx: The second form the will be passed to the originator’s manager. The manager will either approve or reject the request.
  3. BasicApprovalEnd.aspx: The last form that will notify the user of the request result.

Before getting into developing these forms, we need to configure two things. Adding new SourceCode reference and ASPX control. First, right click on the Web Project Icon -> Add Reference -> .NET -> “SourceCode.Workflow.Client”

k2bp6.jpg

The second thing is to add the ASPX Control form K2 BlackMarket (www.k2underground.com). Right click on the VS2005 toolbox -> Choose Items -> .NET Framework Components -> Browse -> Choose the downloaded DLL file “blackpearl.web.controls.dll” and then click OK. Here is the result:

k2bp7.jpg

It’s time to develop the ASPX forms, each page contains the following controls:

  • Subject Textbox: “subject”
  • Message Textbox: “message”

BasicRequest.aspx

We need only to add the submit button “K2Submit” to look like this:

BasicRequest.aspx

Afterwards, add the following code to the submit button’s click event “remember, the code attached is inlined within ASPX tags.”:

k2bp3.jpg

BasicApproval.aspx

Copy and paste the old web form and rename it to “BasicApproval.aspx“. Delete the submit button and replace it with the ASPX Control that we’ve added earlier. Rename the ASPX control to “submit” and check the control’s properties to meet the following:

k2bp8.jpg

Now, let’s us load the workflow data fields according to the workflow item’s serial key.

k2bp9.jpg

Add the following code to the “K2Submit_LoadFields” event:

k2bp11.jpg

BasicApprovalEnd.aspx

This form is identical to the “BasicApproval.aspx” form.

It’s show time now!

The earlier steps are very common for any .NET/ASPX developer. From now on, it’s gonna be nasty and really operative. We’ll publish those forms to a web server through FTP “Even that FTP is not secure, I still love it! since you are not concerned about having Front Page Extensions on the target machine”. Then, we are going to design the BasicApprovalProcess in K2 Designer. Afterwards, we will deploy the process and initiate the process as per our plan.

Before you deploy the web forms, you should enable the “identity impersonate” in the web.config as follows:

k2bp12.jpg

Don’t forget to deploy/copy the “blackpearl.web.controls.dll” to the bin folder in the target website directory path.

Designing the Process

Let’s get back to our K2 Project. Drop two “Default Client Events” into the designer workspace. Here’s the result:

k2bp13.jpg

Activity Configuration

BasicApproval .aspx

Web Form Name: http://ServerName/BasicApproval.aspx

Configure Actions: Add new action, name it “Approval Request”

k2bp14.jpg

Configure Outcomes as following and click Finish.

k2bp15.jpg

BasicApprovalEnd.aspx

Let’s do the same with this activity according to the following:

  • Configure Actions: Name (http://ServerName/BasicApprovalEnd.aspx), Actions: Task Completed
  • Configure Outcomes: Task Completed

Connecting the activities

Now, connect the Start Activity to BasicApproval.aspx Activity (Hold the Ctrl + drag the Start Activity to the BasicApproval.aspx Activity). Also, do the same to the BasicApproval.aspx and BasicApprovalEnd.aspx activities.

k2bp16.jpg

Defining the Data Fields

To map our fields in our web forms, we have to define them first in the K2 Data Fields. From the project workspace (I know that sometimes I use Java terminologies in .NET environment..), view -> K2 Object Browser -> Data Fields -> BasicApprovalProcess -> right click and “Add” -> create the two fields as string “subject” and “message“.

k2bp17.jpg

I guess that we’re ready now to deploy and test the process. Right click on the Solution’s Name “BasicApproval” and choose Deploy. As I always do, click Finish directly in the deployment wizard…

Testing the process

The testing process will start by creating a new instance using the first web form “BasicRequest.aspx”. After that, a work item should be created for the destination user, K2 Workspace can view and operate all these information. The second step is to proceed the process and approve the work item “BasicApproval.aspx“, last thing is to check the returned result “BasicApprovalEnd.aspx“.

k2bp18.jpg

After you submit the form, check the work item flow from the “View Flow” option in Work Item Context Menu in the K2 Workspace

k2bp23.jpg

k2bp21.jpg

Now, let’s Submit and Approve the “BasicApproval.aspx” form.

k2bp20.jpg

The worklist should be updated to reflect the latest activity in the process.
k2bp22.jpg

Last Form to submit is “BasicApprovalEnd.aspx

k2bp24.jpg

Let’s check the process flow after completing all activities.

k2bp25.jpg

Conclusion

K2BP is a helluva BPM solution!. I’ve only scratched the basics of developing, deploying and testing a very simplified workflow process. K2BP can extend these capabilities to integrate with Microsoft Exchange, Office, InfoPath, BizTalk, LCS, Visio and SharePoint.


12 Responses to “BlackPearl Web Forms Workflow..”


  1. 1 Alawi Albrk
    February 21, 2008 at 4:17 pm

    Very nice tutorial about K2; simple steps and to the point.

    AFAIK, MOSS has some sort of workflow support (at least for one-level approval). So, what would it take to develop the same process using MOSS’ designer? Also, what are the limitations of using MOSS workflow alone?

    - Alawi

  2. 2 geek
    February 22, 2008 at 11:16 am

    @Alawi,

    Yup, that’s true. Basically, MOSS Workflow using SPD “Sharepoint Designer” is limited if you compare it to what K2BP can provide. Though, it can be easier and usually quicker to develop such requirements. Not to mention that non-developers can participate to develop those processes. The crux is that SPD workflows can’t handle mid-to-complex processes and sometimes long-running ones. The limitations are in workflow/code reusing, hosting by MOSS only, Workflow’s site within MOSS “You will not be able to use the workflow for multiple sites”, WebServices/Reporting/Monitoring/Profiling can be hectic!. A further step to what I’ve earlier mentioned is that to develop those processes using VS.NET “Visual Studio” which I can proudly say that they’re really awesome! But here, you need a real .NET developer “a .NET/C#/MOSS/WWF jockey”, and I really mean it. It’s not only in the development but more importantly in the problems that could raise.

    IMHO, those requirements can indeed be done using either “SPD/VS.NET” and MUCH MUCH MORE. And think about using off-the-shelf components from CodePlex (http://www.codeplex.com/), they can be of a great help.

    So, the bottom line is: “If you are looking for a Workflow solution and hosted in MOSS platform, go for MOSS workflow. but whenever you think about a BPM “Business Process Management” solution, don’t hesitate to go the way I went… -K2 BlackPearl-”.

    Cheers,
    Saleh

  3. April 7, 2008 at 5:28 am

    A very nice little guide this – highly recommended!

    Martin

  4. 5 Satish Kumar Upadhyay
    June 6, 2008 at 11:04 am

    I am very new for K2. As soon i right click on K2 project i can’t see the add reference option.And you have not mention that user needs to create two separate projects one is for K2 and next one is Asp.Net web site project. Then how to add K2 basic approval in asp.net site. Elaborate more on these steps clearly.

  5. 6 geek
    June 7, 2008 at 8:35 am

    Yup, you are right! You should have two projects in one solution. One for the ASPX “Web Project” and the other for K2 Process “Process Designer”.

    I am not sure which project you meant, but if you’re trying to add a reference to the ASP.NET project, definitely, you should find the Add Reference option. If the case is related to the K2 Process project, “The second thing is to add the ASPX Control form K2 BlackMarket (www.k2underground.com). Right click on the VS2005 toolbox -> Choose Items -> .NET Framework Components -> Browse -> Choose the downloaded DLL file “blackpearl.web.controls.dll” and then click OK”. If you follow the above procedure step-by-step you should be able to create, build, and deploy the project successfully…

  6. 7 Irman
    July 2, 2008 at 11:19 am

    can’t finde any dll like blackpearl.web.controls.dll :( can u provide me with a link to it?

  7. 8 Mohnish Arora
    November 11, 2008 at 9:12 am

    Hi

    I am getting these errors when i try to build “BuildAproval”

    Error 1 No destinations have been added for one or more destination sets on activity ‘BasicApproval’. C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\Basic Approval\Basic Approval\BasicApprovalProcess.kprx 1 1 Basic Approval

    Error 2 The activity ‘BasicApproval’ contains a client event, but the destination rule has not been configured. C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\Basic Approval\Basic Approval\BasicApprovalProcess.kprx 1 1 Basic Approval

    &

    same for BasicApprovalEnd

  8. 9 Mohnish Arora
    November 11, 2008 at 12:35 pm

    Something is missing in the article, i am not able to get the values in Basic approval form.

    Please clearify second & third screen what they are actually doing?

    Since in the article it is given that they are identical,but they are not?

  9. 10 Maheswaran
    June 9, 2009 at 5:18 am

    Very good article.
    I was looking out for something like this.
    Thank you very much


Leave a Reply