Child pages
  • Create a workflow form that uses dynamic REST queries
Skip to end of metadata
Go to start of metadata


Very simple guide to creating an Activiti based workflow form with options that are dynamically populated from a REST query ( though you could use anything really ).

In the example below, Active users will be retrieved, and their usernames will be presented in a selectable drop down list as part of the form.


It is assumed that you already familiar with creating workflows using the Eclipse Activiti designer plugin.

1. Creating a workflow form using a form key

As documented here you need to create a workflow which uses a form task and a form key.

Create a matching selectUserForm.xhtml which will be used to render the form. Note that when you deploy the workflow to OpenIDM you must:

a. Zip the bpmn xml and the xhtml file into a zip file.

b. Rename the zip file extension to .bar e.g.

1. Configure XHTML form

Now we need to configure an XHTML definition for the form task defined above. Consult the OpenIDM samples here or use the example below.

  The contents of this file are subject to the terms of the Common Development and
  Distribution License (the License). You may not use this file except in compliance with the
  You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
  specific language governing permission and limitations under the License.
  When distributing Covered Software, include this CDDL Header Notice in each file and include
  the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
  Header, with the fields enclosed by brackets [] replaced by your own identifying
  information: "Portions Copyrighted [year] [name of copyright owner]".
  Copyright (c) 2011-2015 ForgeRock AS. All rights reserved.
#taskDetails fieldset {
       margin-top: 0;
#taskDetails .field label {
       text-align: left;
#taskDetails .field input,#taskDetails .field select {
       clear: both;
#taskDetails .field .validation-message {
       clear: none !important;
       margin-left: 20px !important;
       float: left !important;
    <h3 class="text-center">Select User</h3>

         <div class="form-group">
            <label class="col-sm-3 control-label" for="selectedUser">User</label>
            <div class="col-sm-6">
                <select class="form-control" id="selectedUser" name="selectedUser">
                    <option value="">Unassigned</option>
<script src=""
<script type="text/javascript">
console.log("In script");
$(document).ready(function () {
	console.log("In function");
                type: "GET",
                url:  "!(status+eq+\"Active\")",
                        data: "",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (data) {
                	console.log("Data retrieved: " + data);
                    $.each(data.result, function (i, theItem) {
                        var combo = document.getElementById("selectedUser");
                        var option = document.createElement("option");
                        option.text = theItem.username.toString();
                        option.value = theItem.username.toString();
                            combo.add(option, null); // Other browsers
                        catch (error) {
                            alert("error found");
                            combo.add(option); // really old browser
                error: function (msg, url, line) {
                    alert("error trapped in error: function(msg, url, line)");
                    alert("msg = " + msg + ", url = " + url + ", line = " + line);

The important bit is the REST call used to retrieve the data:!(status+eq+\"Active\")

The example above will return all users with a status set to "Active".

Once the user makes a choice and submits the form. The user they have chosen will be stored in the "selectedUser" variable. This is dynamically created when the form is submitted. The result of the form can be retrieved in Activiti workflows using "${selectedUser}.



  • No labels


  1. Unknown User (roges14)

    Hello, I'm trying to do, my problem is {"code":403,"reason":"Forbidden","message":"Access denied"}, can't do the REST CALL, 

    try adding headers, but I still given Access Denied
  2. What are the authzRoles of the user you're testing with ? You may need to modify access.js to allow your user to issue such a REST request ..

  3. Unknown User (roges14)

    Hello, thanks for the reply. I'm trying with openidm-authorized user, in which entries must be added this authorization??

  4. openidm-authorized is a default authorization role assigned to managed users so that they can gain access to the self-service, to check or change some of their own profile data for example. That role doesn't allow by default such users to query other users.

    So I'd recommand you to create a new managed role such as myAdminRole, assign that role to some users (in the admin UI, go to the Authorized Roles tab of a user, not to the Provisioning Roles tab !) and then notice the _id property value of myAdminRole (thanks to a REST request).

    Then, you'll need:

    • to allow myAdminRole to access to your workflow (this is done in conf/process-access.json), rather than leaving it available for any user having the authorized-user role
    • to allow myAdminRole to issue REST requests such as the ones used in the workflow above. This is done in script/access.js, and the content below should do the job (b59... is the value of the _id property of your myAdminRole):


                  "pattern"   : "managed/user",

                  "roles"     : "b59c5870-e2aa-43c1-9826-140ad7fcd941",

                  "methods"   : "read,query",

                  "actions"   : "*"


    • please notice you may also wish to restrict the visible fields, but it's another story (wink) ...
  5. Unknown User (roges14)

    I will implement
    Thanks for the support