How to make a new workflow

In this example, we will look at:

  • Adding workflow route for business object
  • Adding command buttons to an edit form of business object
  • Adding history of workflow workflow operations to an edit form of business object

1. Adding workflow route for business object

1.1 Execute CreateWorkflowHistory.sql script. A table with name “WorkflowHistory” will be created in your database. We need this table to save history of workflow workflow operations. 1.2 Open Admin of DWKit 1.3 Open Data Model section. Click Update model link above of the Data Model grid. In the Updating model tree select “WorkflowHistory” table and click Apply button. Data Model item named “WorkflowHistory” must be created. Also check that Data Models "WorkflowInbox", "V_Security_UserRole", "SecurityRole", "SecurityUser" were created. If not - create them. 1.4 Open Workflow section. Click on Create link button above of the Workflow grid. 1.5 Fill Code field with “Invoice”. Click on the Save button. 1.6 Click on Choose file button in Workflow Designer select SchemeInvoice.xml, click on Upload Scheme button than click on the Save button in Workflow Designer.

Screenshots:

Screenshot 1

In this route there are actors “Manger” and “Boss” because there are no more Roles in demo system except “Admin”. Both are checked that current user is in “Admin” role. To change this behavior you need to add new roles in the demo system, and specify theirs codes as Value for actors.

2. Adding command buttons to an edit form of business object

2.1 Open Form section. Click on “Invoice_Edit” form in the Forms grid. 2.2 To add new Block in this Form click on Create link button above of the Blocks grid. Fill Name field with “WorkflowCommands”, Order field with 1, choose “Commands of workflow” as Template.

Click on Load params button near Template params label. You will see:

@EntityName=
@FormCustomSave=FormCustomSave

in Template params field. Fill this field as:

@EntityName=Invoice
@FormCustomSave=FormCustomSave

Click on the Save and Exit button.

2.3 To add new Function to this Form click on Create link button above of the Functions grid. Fill Type field with “Form handler”, choose “DefaultWorkflowFormHandler” as Function. Click on the Save and Exit button.

This function get the list of availiable commands from Workflow Runtime and put it on form.

Screenshots:

Screenshot 2

Now if you opened invoce which is not attached to the route you will see “Start” button. If you push it workflow will be created and State will be changed. History of workflow workflow operations stored in WorkflowHistory table.

3. Adding history of workflow operations to an edit form of business object

Add grid for view the history of workflow operations as shown in "How to add details (related grid) to business object" tutorial.

You need to complete steps 1.4 - 1.6 in this tutorial for create “WorkflowHistory” View. Add “ISNULL(Date,CONVERT(datetime, '2999-12-31', 120)) ASC, StateOrder ASC” as Default sort for this View.

You need to complete steps 2.1 - 2.5 in this tutorial to add the grid on the form.

When you add “Dependent” block to form (step 2.4), specify the following parameters

@ViewName=WorkflowHistory
@Prefix=form
@Height=250px
@BaseEntityIdName=ProcessId
@BaseEntityIdValue=@id
@CustomSave=true

Do not complete step 2.6.

Screenshots:

Screenshot 3 Screenshot 4

Now you can view history of workflow operations in that form.