XAF – Finally…Workflow It! (coming in v2011 vol1)


We are happy to announce that in v2011 vol1 version of the eXpressApp Framework, we have finally supported popular workflow scenarios, starting from simple and finishing by very complex ones. In this introduction blog post, we will dig into what actually workflow is and describe what we implemented in our framework for its support.


Windows Workflow Foundation 4.0 support!

As part of workflow integration in XAF, we supported Windows Workflow Foundation 4.0 (WWF).  Briefly, it provides “a programming model, in-process workflow engine and rehostable designer to implement long-running processes as workflows within .NET applications”.

Fortunately for us, Microsoft already did a lot describing main benefits of their technology to developers, and we can use these ready materials to easily introduce you to workflow integration in our product.

I suggest you get started with understanding the “workflow way” from the following article:

and then continue with the following ones:

, describing specifics of the WWF technology itself.


In these links, you will learn that you can use WWF to model in a declarative way complex business scenarios by creating Activities in a visual designer. Activities are functionality parts of different scales: from the atomic to entire business process descriptions. The .NET Framework provides a library of activities (such as WriteLine, an activity that writes text to the console or other form of output). Custom activities can also be developed for additional functionality, and a lot more!

Primary supported WWF scenarios

Our primary goals while implementing workflow integration in XAF were the following:

  • provide an easy way to model business process as activities and workflows;
  • provide access to XPO business objects from Workflow Activities, including support for CRUD operations;
  • host workflows and run them for certain objects;
  • persist long running workflows in the XPO database;
  • track and control states of running workflows.

We plan to describe these aspects in greater detail in the next blog series:

  • XAF Workflow Visual Designer;
  • Working with XAF CRUD activities;
  • Hosting and launching workflows;
  • XAF Workflow persistence storage;
  • Tracking workflows;
  • Reusing custom activities;

If you would like us to cover more scenarios, or want to confirm whether certain tasks are appropriate for using WWF, please let us know in the comments to this blog. We will be happy to hear your thoughts.

Support for lightweight workflow scenarios

Usually, Windows Workflow Foundation is worth using in complex scenarios, e.g. documents flow control in an enterprise. So, it may often require configuring a server for workflow hosting. It adds unwanted complexity, and hence, it may not fit well in simple scenarios, such as objects status management. Of course, WWF still can be used for such scenarios, but it will be like lighting a cigarette from a nuclear reactor, if you see what I mean.

For the latter scenario (objects status management) it is more suitable to use the lightweight State Machine module, which is also coming in 11.1. Getting started with this module will not consume considerable resources, including learning the WWF technology. That is very important for small businesses, and so it makes the State Machine module a good alternative to WWF. We will describe this new module in a future blog.

Why is this feature useful for you?

Like any feature or technology, it requires understanding what it is, why it is useful, and when it makes sense to use it. Let us start with a brief description of “workflow” from Wikipedia:

“A workflow consists of a sequence of connected steps. It is a depiction of a sequence of operations, declared as work of a person, a group of persons, an organization of staff, or one or more simple or complex mechanisms. Workflow may be seen as any abstraction of real work. For control purposes, workflow may be a view on real work under a chosen aspect, thus serving as a virtual representation of actual work. The flow being described may refer to a document or product that is being transferred from one step to another.

A workflow is a model to represent real work for further assessment, e.g., for describing a reliably repeatable sequence of operations. More abstractly, a workflow is a pattern of activity enabled by a systematic organization of resources, defined roles and mass, energy and information flows, into a work process that can be documented and learned. Workflows are designed to achieve processing intents of some sort, such as physical transformation, service provision, or information processing.”

As you see, almost everything you can do in your business applications “breathes” with workflows. For better understanding, I would prefer to get away from this abstract and scientific description, and stay with something more concrete. Let’s demonstrate how to implement a simple incoming issues process scenario. So, here we go.

Suppose we have two classes: Issue and Task. A new task should be created when an active issue appears. It is necessary to inform an end user that there is work to do. The Issue and Task classes are very simple:

  1: [DefaultClassOptions]
  2: [DefaultProperty("Subject")]
  3: public class Issue : BaseObject {
  4:     private string subject;
  5:     private bool active;
  6:     public Issue(Session session) : base(session) { }
  7:     public string Subject {
  8:         get { return subject; }
  9:         set { SetPropertyValue("Subject", ref subject, value); }
 10:     }
 11:     public bool Active {
 12:         get { return active; }
 13:         set { SetPropertyValue("Active", ref active, value); }
 14:     }
 15: }
 16: [DefaultClassOptions]
 17: public class Task : BaseObject {
 18:     private string subject;
 19:     private Issue issue;
 20:     public Task(Session session) : base(session) { }
 21:     public string Subject {
 22:         get { return subject; }
 23:         set { SetPropertyValue("Subject", ref subject, value); }
 24:     }
 25:     public Issue Issue {
 26:         get { return issue; }
 27:         set { SetPropertyValue("Issue", ref issue, value); }
 28:     }
 29: }

Previously, we would implement some hard-coded business logic, but now, with the help of the Windows Workflow Foundation functionality, we can easily get the same or better result using the Workflow Designer and the built-in DevExpress.Workflow.Activities library.

First, we will add a Class Library for our custom workflow activities (it is WorkflowDemo.Activities in the screenshot below). Since Issue and Task are pure persistent objects, and we want to perform CRUD operations with them, we need to add a reference to DevExpress.Workflow.Activities, which contains appropriate activities.

We will add a new Activity into our WorkflowDemo.Activities project and name it CreateUserTask and then construct it using the designer:

01 - CreateUserTask

As you can see in screenshot above, there is an ObjectSpaceTransactionScope activity, containing several activities. This activity encapsulates a data access layer (including ConnectionString) and blocks for workflow persisting. The reason for the persistence block is that persistent objects most often are not serializable.

The first activity inside the ObjectSpaceTransactionScope is a TransactionalCreateObject<Task> activity that creates a new Task object.

Then, the TransactionalGetObjectByKey<Issue> activity loads an issue with a passed Id from a database.

Next, two Assign activities set the Issue and Subject properties of the created Task.

The TransactionalCommitChanges activity commits all the changes we made in the database.

And the last Assign activity sets the CreatedTaskId result parameter.

Also, we created several auxiliary variables and arguments that were used to pass data between activities.

Now, we have designed a workflow activity that implements simplified incoming issues processing, and can run it as a typical workflow. For example, we can publish it as a WCF service, add a controller with the "Start 'Process Issue' workflow" action into a WorkflowDemo.Module project and simply make a call to the published service. Another approach is to start the workflow automatically when a new Issue appears: it could be implemented via a separate application that periodically searches issues by the "Active = true" criteria and start the workflow for each issue found.

Now, if we create new active Issue in the client application, CreateUserTask activity will create a new Task for that issue:


Since the main workflow scenario will be creation of activities at runtime, we also provided a runtime workflow designer that can be invoked in every XAF Windows Forms application:




We also supported scenarios such as automatic database scanning for workflow target objects (see the 'Target Object Type' and 'Criteria' properties on the Workflow definition Detail View) and made it possible to implement a workflow server that can receive requests to start workflows, load workflow definitions from the database, etc.

Related Links

Online documentation
How-to & Blog posts

Looking forward to your feedback!

We know that a lot of XAFers were longing for this feature for many years, and so we are eager to receive your feedback.

Do you like this feature?
Do you see a place for it in your XAF arsenal?

Please tell us your thoughts in comments to this blog!

Happy XAFing!Winking smile

28 comment(s)
Nate Laff

YAAAAY!!! I have several areas where I intend to remove logic from the business objects themselves and place them in workflows. Excited to try it out.

5 May, 2011
Steven Rasmussen

This is simply fantastic!  Have been waiting a long time for this.

I noticed that a workflow can be triggered whan the object is 'Created'.  Is there an option for when an object is 'Updated'?  If the object is updated is there any way to specify that the workflow fire only if certain properties of the object are changed? (Maybe that's what the 'Object Fits Criteria' is trying to accomplish?)

Also, hopefully the 'Object Fits Criteria' is a criteria property editor so that we can build the criteria in the editor with intellisense etc.

Would it be possible to manually run a workflow by pressing a button?

Is the workflow object itself extensible meaning that I could put my own properties on it as well? Ie 'Allow manual execution' boolean property.  If yes then I could have a controller create a dropdown of all the workflows on an object avaialbe for manual execution.

Anwyway, those are enough questions for now :)  Many more to come.  This is great stuff though!

5 May, 2011
Andre Labaki

First of all I would like to say: Thank you! It was becoming a headache hard-coding all the workflows for my client's applications!

Secondly, I have a couple of questions:

1. Will the workflow integration work on Web applications? If so, I am assuming that the "runtime workflow designer" will work on windows forms only. If that is the case, will there be a standalone windows-based tool that will allow us to design the workflows for web applications?

2. You mentioned that "We also supported scenarios such as automatic database scanning for workflow target objects..." Does that mean that XAF will ship with a server that will be monitoring these object and automatically start a workflow?

Again, thanks for this amazing feature which I have been longing for!

5 May, 2011
michael iacoviello

what is the plan for the workflow host?  Is there a service to host asynch. workflows or are they hosted in iis?

5 May, 2011
Robert Fuchs

Finally!!! Have been waiting for this since 2006! *)

*) For those that don't know: XAF already had WF in the CTP and then was removed :-(

5 May, 2011
Martin Praxmarer - DevExpress MVP

Amazing Job Guys - absolut great to have WF finally integrated in XAF!

5 May, 2011
Nate Laff

Also interested in the inheritance. For my example, I would want some of these to be configurable per user.

5 May, 2011
Mohsen Benkhellat

Indeed I have been waiting for this since 2006 also.

Awesome effort from DX.

5 May, 2011
Guillermo Vilas

Well done!!

Thanks DX

5 May, 2011
Kevin Wang


I have been wating for this serval yeas ago.

5 May, 2011
gerald antony


 Thanks! it is fantastic. Is it possible to use state machine module code in simple dotnet applications?(and not in xaf applications)


5 May, 2011
Alain Bismark

Finally!!!, thanks!!...I need to re-wrote my Skelta code but is great!

5 May, 2011
Dima Janzen


6 May, 2011
Alois Kleine


Waiting two years for this!

6 May, 2011

Very cool! Thanks guys!

6 May, 2011
Dan (DevExpress)

>If the object is updated

Generally speaking, the 'Created' start condition, as well as the 'Modified' condition, can be correctly processed only with the help of a middle tier: it simply checks incoming updates and starts workflows based on them.

We have tried this approach but we are not ready to published it yet. We need to test it carefully and achieve the proper stability and performance.

Currently, we suggest you place this logic into the OnSaving method of business classes. This approach is very similar to a real "middle tier", except that the workflow start code is placed inside business classes and works on the client. We have used this approach in our WorkflowDemo and you can review and try it when the release is published.

Currently, 'Object Fits to Criteria' is processed in the '3rd user' manner: there is a scheduled service on WorkflowServer that periodically searches for objects that meet criteria and don't have a started workflow yet. In other words, a workflow is started for an object once.

> manually run

We have not implemented this option yet. We'll try to include it in the final version. Anyway, it is very easy to implement it manually.

>I could put my own properties

Of course. The WorkflowDefinition is a common business class, and you can extend it in any way.

> work on Web applications

Yes. Generally speaking, workflows are not related to an application platform.

>a standalone windows-based tool  to design the workflows

The WorkflowDefinition is a common business class and this tool is a simple XAF WindowsForms application. We don't provide a precompiled tool because there could be different implementations of the WorkflowDefinition (at the end, the system requires the IWorkflowDefinition interface only), and it is very easy to accomplish it manually. Also, there could be additional variable aspects, such as Security, Controllers, Audit and so on. This is because we don't provide such a tool.

>Is there a service to host asynch. workflows or are they hosted in iis?

We have introduced the WorkflowServer class, which creates a WorkflowHost object for each active WorkflowDefinition, allows starting new instances without ASP.Net WCF services and additional Receive activity, attaches a persistence store and necessary extensions to access the database, handles exceptions, refreshes hosts and so on. This class is not related to IIS, and it can be deployed as a console application or Windows Service.

>Also interested in the inheritance

Could you describe it in greater details?

>configurable per user

Could you describe it in greater details? Anyway, you can access the database from your workflow and read the User information. Also, a workflow instance is started on the 'server' (it is not a client computer), and all the workflow instances are run under one and the same user (we suggest introducing a new 'Workflow Service' user for this purpose).

> XAF will ship with a server

Yes. There is a separate class (WorkflowServer) that can be deployed to a console application or Windows Service or in any other way. For simplicity, in the WorkflowDemo application, we decided to start it in a separate AppDomain of the same process. Anyway, we have added a new Project Template to Visual Studio to create it as a Windows Service.

>Is it possible to use state machine module code in simple .Net applications

Yes, it is possible. Though, the StateMachine module provides great visualization for available actions and values based on the State Machine interfaces, so you will get reduced functionality in a separate .NET application. Some code requires XAF to run.

6 May, 2011
Nate Laff

>configurable per user

>> Could you describe it in greater details? Anyway, you can access the database from your workflow and read the User information. Also, a workflow instance is started on the 'server' (it is not a client computer), and all the workflow instances are run under one and the same user (we suggest introducing a new 'Workflow Service' user for this purpose).

My thinking was I might want some users in the security system to have workflows enabled, where others might not, but I came up with something else, so it's not a big deal :)

6 May, 2011
James Zhong

Workflow in XAF will help both developers and end users to define comprehensive business processes.

Will the workflow support these three complex approval process?

1. Multi-level approval (escalation);

2. Branched AND approval;

3. Branched OR approval.

6 May, 2011
Fırat Esmer

Thanks guys, it's amazing!

7 May, 2011
michael iacoviello

Excellent, this is great news!  I have to ask when we can expect 2011.1 to be released?  I've created my own workflow module because nothing was written in stone yet, but would definitely rather implement the native XAF workflow features.  Any rough estimates?

7 May, 2011
michael iacoviello

I notice you stated you started it in a different appDomain of the same process for each workflow definition that is loaded.  Are you finding that the service process memory consumption continues to increase and never releases the appDomains unless it is restarted?  Is there a plan to run the appDomains in a separate process that can be unloaded?

7 May, 2011
Dan (DevExpress)

>Will the workflow support these three complex approval process

I believe the answer is Yes. The workflow is a tool from Microsoft to automate some processes, and XAF is now integrated with this tool: in v11.1, we have made it easy to create various workflows, but don't provide ready-to-use workflows.

>started it in a different appDomain of the same process for each workflow definition

No, the entire workflow server is started in a separate domain in our primary workflow demo. Then, the workflow server doesn't create domains and starts all the workflow instances in the same process and AppDomain. We use it in our internal applications and don't find significant requirements to memory or processor: most of the time all the workflow instances are 'sleeping' and unloaded from the memory to a database. So, there is a few number of working instances in memory at any time.

10 May, 2011
michael iacoviello

Thats great, thanks Dan.  My experience with AppDomains is the loading of the assmeblies (and referenced assemblies) don't get unloaded until the host process is unloaded.  Thanks for the info, and I'm really looking forward to this release.

11 May, 2011
luo lin

Really good, looking forward to ...

12 May, 2011
Adrian Popa 2

First of all I'm newbie on XAF, so please be pacient :)

I'd like to enable the end user to show/hide UI elements from a page/screen based on sets of business rules. The business rules will be defined at <b>runtime</b> using the integrated WF editor. The rules will contain a mix of Model and View elements and are Visual Basic expressions (WF default expression engine)

Now looking to the "WF integration in XAF" and "Conditional Editor State module" I'm wondering if I can achieve my requirements out of the box.

20 May, 2011
Dennis (DevExpress Support)


In my opinion, the new State Machine module will be more suitable here: community.devexpress.com/.../state-machine-module-introduction.aspx

Also, please use the Contional Appearance module instead of Conditional Editor State: community.devexpress.com/.../xaf-eliminating-the-number-of-conditional-something-coming-in-v2011-vol1.aspx

Please contact our Support Team if you need any further assistance on this. We will be glad to help you.

1 June, 2011
Alekseev Gleb

What control was used to display the nice diagram in "Introduction" ?

20 April, 2012
Dennis (DevExpress Support)

This control is a part of the rehosted workflow designer.

20 April, 2012

Please login or register to post comments.