You are on page 1of 2

Redirect URL tutorial

Product version:
6.5, 6.4
Product edition:

Teamwork
Efficiency
Performance

This page contains an example of how to use a PHP form in a human task in place of a form defined in
Bonita BPM Studio. It shows how to send a variable value to a form, and how to retrieve a value from the
form and save it to a variable. The form is displayed by a servlet in Bonita BPM Portal, which
communicates with Bonita BPM Engine. This means that the Portal must be running. You also need a web
server. This example was created with a Apache web server, which was running on the same node as Bonita
BPM Portal so the URLs reference localhost. Make sure that your web server is running before you run the
process.

There are two stages:

Create the process definition


Write the PHP code

When you have created the process definition and deployed the PHP code, you can run the process to test the
PHP form.

Create the process definition


Follow these steps:

1. In your process definition, add two variables, data1 and data2, with type text. The value of data1 is
sent to the form. In the form there is a field called Feedback. The value of data2 is set by the value
entered by the user on the form.
2. Add two human tasks to your diagram (one can be the Step1 task that is created by default when you
create a new diagram).
3. Select the first human task, and go to the Details panel, Application tab.
4. Check the Redirect to URL radio button.
5. In the Redirect to URL field, specify a Groovy expression for the URL. To do this:
a. Click the pencil icon to open the expression editor.
b. In the Expression type list, select Script.
c. Enter the script name,
http://localhost/example_redirectURL.php?param1=${data1}.
d. Enter the expression:
return "http://localhost/example_redirectURL.php?param1="+
data1;
e. Click OK.
6. Check the box Define the return URL as a parameter.
7. Specify an expression to retrieve the value entered in the feedback field of the form and write is to
data2. The Application tab should now look like this:
8. Select the second human task, and create a form for it that will display the value of data2. When you
run your process, this will show that the value you enter in the PHP form.

Write the PHP code


You need to create PHP code with the following content:

$v) { $name = strstr($v,"=",true); $value = substr(strstr($v,"="),1);


echo "\n"; } ?>
Save this PHP code in a file called example_redirectURL.php and deploy it in your web server.

The PHP code builds an HTML page on the fly, which can be displayed in any web browser. The form
contains a field called feedback where the user can enter some text, and some hidden field that are not
displayed. The form HTML is similar to this:

The user enters a value, for example veryGood, in the feedback and submits the form. When the form is
submitted, the browser sends to the webserver the hidden information and the feedback value entered by the
user to a Java servlet, executeactionservice. This servlet passes the data to the Bonita BPM Engine which
then redirects to the Bonita BPM Portal confirmation page URL, for example:
http://localhost:8080/bonita/portal/homepage?ui=form#feedback=veryGood&form=ex
redirectURL-63--1.0--
Step12$entry&task=2&getNextForm=true&assignTask=true&mode=app

Test the process and display the PHP form


Click Run and run the process. An automatic process instantiation form, created from the data you specified,
is displayed. Fill in this form to start the process instance, and access the first human task. This is where you
defined the redirect URL, so you will see the PHP form. Enter a value in the "feedback" field, and proceed to
the final step. In this step, you will see the value that you enterd in the PHP form.

© 2018 Bonitasoft, Inc. All rights reserved.

You might also like