Building your First Workflow Process

. 1. 2

Design the Workflow Process

Prepare the Forms

Define Activities for the Interactive Tasks

Define Workflow Process Attributes and Mappings

Associate a Business View with the LAPTOP Process

Define Activities for the System Tasks

Testing the LAPTOP Process in the Ebase Designer

Testing the LAPTOP Process outside of the Ebase Designer

 

See also:         

Introduction to Workflow

Workflow Concepts

 

Prerequisites for running this tutorial:

 

1.      The Ebase_Workflow_Server and Ebase_Workflow_Client modules are both licensed (in the Ebase Designer check Help -> Licence, both modules should appear under Installed Features).

2.      Authentication of runtime users is enabled. To enable the Ebase supplied authentication, uncomment the following statement in UFSSetup.properties: Ufs.logonExitServlet=LogonExitServlet, and restart the Ebase Server.

 

This tutorial will lead you step by step through the process of creating a simple workflow process. The process has three steps:

 

1.      A user makes a request for a new laptop via an electronic form.

2.      The request is routed to another user who is responsible for approving or rejecting such requests.

3.      The originating user is informed of the approval or rejection decision via an email.

 

In terms of workflow this process will be implemented as two interactive tasks i.e. the laptop request step and the subsequent approval/rejection step, and one system task responsible for issuing the email notification back to the requesting user. The interactive tasks will be implemented as Ebase forms. The tutorial assumes that the reader is familiar with Ebase development concepts such as forms, business views, resources and FPL.

 

Part 1: Design the Workflow Process

 

  • Start the Ebase Designer
  • Create a new workflow process (File -> New -> Workflow -> Process) called LAPTOP.
  • Click on the task node icon . Click anywhere on the page to add the task node. Double click on it to change the name to LT_REQUEST. Repeat this twice and name the task nodes LT_APPROVE and LT_EMAIL.
  • Link the tasks START -> LT_REQUEST -> LT_APPROVE -> LT_EMAIL -> FINISH by clicking the  icon and dragging the arrow between the task nodes. Make sure they are linked correctly so when you move a task node the left or right, the arrow moves along with it. Right-click on each link and select Configure to rename the links from the default to ‘start’, ‘request’, ‘approval’ and ‘completion’ respectively. Position each link name in the middle of the link by right clicking on the link and selecting Link... -> Label Link in the middle.

    (Hint: you can achieve vertical alignment by selecting everything – draw a rectangle around all items – then right click and choose Align… -> Align centres vertically). 

    Your process should now look like: 

 

 

 


 

Change the task descriptions:

 

  • Edit the LT_REQUEST task configuration by double-clicking the icon. Set the description to be ‘Laptop Request’
  • Edit the LT_APPROVE task configuration.  Set the description to be ‘Laptop Approval’.

 

Part 2: Prepare the Forms

 

The LAPTOP process requires two Ebase forms to operate: one to enable a user to request a Laptop and one to enable Bob to approve or reject the request. The forms (and the sequence used) are shipped with the Ebase Workflow product and need to be copied from UfsServer/samples/workflow directory to the transport directory.  

 

laptop_forms.xml

laptop_sequences.XML

 

Import the files (Tools -> Migration -> Import). (See Using Import and Export for more information)

 

The import will create a project folder called LAPTOP and create two forms: LAPTOP_REQUEST and LAPTOP_APPROVAL.  The forms are fully functional but must now be enabled to work with the LAPTOP workflow process:

 

Open form LAPTOP_REQUEST. On submission the form must start a new LAPTOP process and complete the first task defined in the LAPTOP process at the same time. In addition, relevant data must be passed to the LAPTOP process so it may be passed later on to other defined tasks. The form collects the following data:

 

APPLICANT_EMAIL

- the email address of the user making the request

APPLICANT

- the name of the user making the request

APPLICATION_ID

- a unique reference number allocated to the request

ID

- the product identifier of the selected Laptop

PRICE

- the price of the Laptop

DESCRIPTION

- the description of the Laptop

 

These fields must be defined as ‘Workflow out parameters’ i.e. their values will be passed to the LAPTOP workflow process:

 

Go to Form Properties -> Workflow -> Workflow out parameters and add the above form fields to the ‘Workflow out parameters’ box.
(Hint: You can control-click to select multiple fields).

 

We will also define a single Completion State for this form: value COMPLETE. Click on the ‘+’ icon next to the ‘Workflow completion states’ box and type in ‘COMPLETE’.

Save the form.

 


 

 

 

 

We must also workflow enable the LAPTOP_APPROVAL form. This form receives data values from the LAPTOP process i.e. that describe the item requested, and passes back an approved or rejected status. If the request is rejected the form also passes back a rejection reason. To enable this we must define:

 

APPLICANT

APPLICATION_ID

PRICE

DESCRIPTION

ID

 

as ‘Workflow in parameters’.

 

Also add ‘REJECTION _REASON’ as a ‘Workflow out parameter’. We will also define two ‘Workflow completion states’: APPROVED and REJECTED.

 

Save the form.

 


 

 

Part 3: Define Activities for the Interactive Tasks

 

We must now define Activities to associate each of the interactive workflow tasks LT_REQUEST and LT_APPROVE, with the LAPTOP_REQUEST and LAPTOP_APPROVAL forms.

 

In the Workflow process, double-click the LT_REQUEST task and set the Activity type to be Interactive. Create a new Activity by clicking the  icon and name it ‘LT_REQUEST’.

 


 

The Activity configuration screen will open. Choose the Activity Type to be ‘Ebase Form Activity’. Choose the Form Name from the list to be LAPTOP_REQUEST. The Input Parameters, Output Parameters and Completion States will be imported automatically from the LAPTOP_REQUEST workflow properties i.e.

 

 

Save the Activity.

 

Double-click the LT_REQUEST task again and click on the Resources tab.  Set the resource allocation to ‘Public’.

 

 

 

 

Repeat the exercise for the LT_APPROVE task. Create a new Activity called ‘LT_APPROVE’, associated with form LAPTOP_APPROVAL.

 

 


 

Again, Save the Activity.

 

We have now associated the Ebase forms LAPTOP_REQUEST and LAPTOP_APPROVAL with the tasks LT_REQUEST and LT_APPROVE. The association is implemented via the interactive Activities LT_REQUEST and LT_RESPONSE respectively.

 

 

We will now configure the assignment of the approval task. For simplicity, we will allocate this task to a user called Bob. In the real world this is not realistic: it is far more likely that the approver will be the requestor’s line manager. This type of dynamic allocation of resources to tasks is fully supported by the Ebase workflow system.

 

  • Create an Ebase user called Bob, password Bob (Tools -> Maintain Security -> New User). Assign Bob a role of SUPER_USER.
  • In the Workflow Process , edit the LT_APPROVE task configuration.  Assign the task to user Bob by clicking the Resources tab, selecting Named resource and entering ‘Bob’ in the data entry field.

 

 

Part 4: Define Process Attributes and Mappings

 

We must now define the Process Attributes that will hold the data being passed in and out of the process via the Ebase forms.

In the Workflow Process, click on the vertical Show Process Attributes text on the far right of the screen:

Add attributes as follows:

 


 

Save the LAPTOP process.

 

Note: the process attributes EMAIL_FROM and APPROVAL_MESSAGE: these will be used subsequently in a System Task to issue notification email.

 

We must now map task node Input and Output Parameters to the Process Attributes. Double-click the LT_REQUEST task node and select the Mappings tab. Map the parameters and process attributes as follows:

 


 

Repeat the exercise for Task LT_APPROVE:

 

         

 

Note that the LT_APPROVE task has both Input and Output parameters i.e. the input parameters describe the Laptop request to Bob and the output parameter contains a rejection reason (if the request is rejected). The LT_REQUEST task however is the starting point of the process and therefore has no input parameters.

 

 

Part 5: Associate a Business View with the LAPTOP process

 

We have one System Task, called LT_EMAIL. The function of this task is to automatically send an email notification to the originator of the Laptop request. To implement this functionality we must create:

 

  • A new Business View called LAPTOP. File -> New -> Business View.
  • An Email Resource called LT_APPROVAL_NOTIFICATION defined as follows:
    File -> New -> External Resource -> Email Resource.

         

 

 


Save the Email Resource.

 

Add the LT_APPROVAL_NOTIFICATION Email Resource to the LAPTOP Business View. Save and Close.

 

We now associate LAPTOP Business View with the LAPTOP Process by clicking the  icon on the Workflow Process designer. Choose Business View LAPTOP from the drop down list:

 


 

Map the Email Resource fields to the Process Attributes by clicking the  icon, as follows:

 


 

(See Working with Business Views and Working with Email for more information)

 

 

Part 6: Define Activities for the System Tasks

 

We must define a new System Activity called LT_EMAIL. Double-click the LT_EMAIL task, choose System as the Activity type and click the  icon. System tasks are implemented as FPL scripts. Create an FPL script as follows:

 

// send an approval or rejection email...

//

if [$COMPLETION_STATE = 'APPROVED']

   set approval_message = 'Your application Reference No. ' + application_id + ' for a LAPTOP - ' + description + ' has been approved.';

else

   set approval_message = 'Your application Reference No. ' + application_id + ' for a LAPTOP - ' + description + ' has been rejected: ' + rejection_reason + '.';

endif

 

// send a notification email...

//

sendmail lt_approval_notification;

 

 

          

 

 

 


Save the Activity.

 

The LT_EMAIL Activity constructs a notification message based on the Completion State returned by the LT_APPROVE task, and then sends the email.

 

Part 7: Testing the LAPTOP Process in the Designer

 

The LAPTOP process may be tested by clicking the  icon on the Workflow Process designer toolbar. Click OK on the Process Input Parameters dialog (there are no input parameters for the process); the Process Tester will then appear:

 

 

 

Click Start to begin the process. Each task will be processed in turn. For each Task, you will be able to enter values for input and output parameters, and choose Completion States.

The first Task is LT_REQUEST: enter values for the output parameters as follows and click the ‘Complete task and step’ button:

 

 

 

 

 


The screen for the second Task, LT_APPROVE, will appear. Choose a Completion State of REJECT and enter a Rejection reason as ‘Sorry, no budget’. Click the ‘Complete task and step’ button.

 

 

 

 

 


The process now moves on to the System task LT_EMAIL.

 

 

 

 

Click the Step button to continue. The LT_EMAIL task is executed i.e. an email is sent to the originator of the Laptop request with an appropriate notification message. The process is now complete:

 


 

Note: The Process Tester actually executes the process for real i.e. it is not a simulation. As a result of executing the test an email will be despatched to the email address entered during the completion of the LT_REQUEST task.

 

Part 8: Testing the LAPTOP Process outside of the Designer

 

Before testing outside of the Designer, the process must be ‘Released’ by clicking the  icon on the Workflow Process designer toolbar.

 

The LAPTOP process may now be tested directly from the web browser. Start a web browser and enter a URL to run the LAPTOP_REQUEST form e.g.

 

http://localhost:3030/ufs/ufsmain?formid=LAPTOP_REQUEST

 

At the authentication prompt enter your usual Designer username and password. The LAPTOP_REQUEST form will appear.

 

Enter a value for name and email address, choose a laptop and click submit. The form starts a LAPTOP process passing in the relevant data.

 

 

 

Close the web browser completely.

 

The next task in the process is LT_APPROVE. This task is assigned to a user called Bob. This means that it will appear as a task item on Bob’s task list. We must therefore run the WF_TASKLIST form, which is shipped with the Ebase Workflow product as a sample task list application. Start a web browser and enter a URL to run the WF_TASKLIST form e.g.

 

http://localhost:3030/ufs/ufsmain?formid=WF_TASKLIST

 

At the authentication prompt we must sign in this time as user Bob (password Bob) N.B. Usernames and passwords are case sensitive. Note that the authentication prompt is only displayed for new sessions, so you may need to close all open browser windows then open a new browser and enter the URL for the WF_TASKLIST form.

 

The sample task list will appear containing any tasks allocated to Bob that he has yet to action:

 

 

 

The task is already assigned to Bob so tick the Select box and click the Open Task button. The LAPTOP_APPROVE form will be automatically invoked, passing in the data describing the Laptop requested. Bob must now decide whether to approve or reject the request. Enter a rejection reason of ‘Sorry, no budget.’ and click the Reject button. The form will pass the rejection reason and a Completion State of REJECTED to the workflow process.

 

 

The final task, LT_EMAIL, will now execute and the process execution is complete. Correct execution of the LT_EMAIL task may be verified by checking the Execution log (View -> Execution Log).

 

 

 

 

Solution

The complete solution to the tutorial may be imported from the following export files shipped with the product:

 

LAPTOP_FORMS_COMPLETE.XML

- the LAPTOP_REQUEST and LAPTOP_APPROVE forms including input and output parameters, and defined Completion States.

LAPTOP_SEQUENCES.XML

- the LAPTOP sequence used by the LAPTOP_REQUEST form.

LAPTOP_PROCESS_COMPLETE.XML

- the LAPTOP process; LT_REQUEST, LT_APPROVE and LT_EMAIL Activities; LAPTOP Business View and LT_APPROVAL_NOTIFICATION Email Resource

 

You will first need to copy the files from UfsServer/samples/workflow directory to the transport directory and then import them using the tools menu (Tools -> Migration -> Import).

 

(See Using Import and Export for more information)