cancel
Showing results for 
Search instead for 
Did you mean: 

Two forms following each other

mlomo
Champ in-the-making
Champ in-the-making
Hi
Is it possible to have two forms following each other? So the user is presented form A, fills in the form, presses Next and then is presented another form B which contains more data based on the data typed in in form A. For example, in the first form the user enters user-ID. The user-ID is used to look firstname and lastname from a database. This is presented in form B.

I have implemented form A in a Start Task. Then I lookup data in a Script Task and present the result in a third task, a User Task. The problem with this is that the user, after having filled in form A, has to go through assigning a task to himself and them opening the task. This is not very user friendly. I would like form B to follow straight after form A.

Or even better, if I could have everything done in one form. But then I guess I need som magic (Ajax??)

I would appreciate any help on this. I use Activiti Designer in Eclipse.

Thanks
Morten

5 REPLIES 5

mlomo
Champ in-the-making
Champ in-the-making
Another implementation that I´ve been thinking about, is to make the whole user table into a process variable so that it will be available on the client side in form A. In this way I can use JavaScript on the client side to search the table to find first name and last name based on the user-ID that the user types in. This way I don´t need a second form. However, with more than 1000 users in the user table, I will be sending a lot of data to the client side. Is this a good design?

Morten

jbarrez
Star Contributor
Star Contributor
"Or even better, if I could have everything done in one form. But then I guess I need som magic (Ajax??)"

yes indeed. Assuming you're talking about Activiti Explorer.

"Is this a good design?"

No, it's not a good idea to store large variables. This will be bad for query performance. Store an identifier as variable, and store the actual data somewhere external and reference it when needed.

mlomo
Champ in-the-making
Champ in-the-making
Hi,
Thanks. This was very helpful. OK, so I need some Ajax. I´m using Activity in OpenIDM from Forgerock. My workflow is designed with Activiti Designer in Eclipse. So I´m not using Activiti Explorer, I´m afraid. My forms are done with activity:formKey. So I have a separate .xhtml file for each form. In my .xhtml file I have this code:

<code>
   <div class="form-group">
        <label class="col-sm-3 control-label" for="workerId">Worker ID</label>
        <div class="col-sm-8">
            <input class="form-control" type="text" name="workerId" />
        </div>
    </div>
</code>

to get hold of the worker ID from the user input and put it into the process variable workerId.

If I understand correctly, I now need to use workerId to lookup data in the database (for example first name, last name, ..) on the server side and send it to the client side. All happening in the same Task. This is where I´m lost and need some help. Do you have some hints or some example code that can point me in the right direction?

Thank for any help.

Morten

jbarrez
Star Contributor
Star Contributor
I'm not familiar with how Activiti is integrated within openIDM nor how the forms work there… so I'm not sure what you need to do to make it work. In a typical Activiti setup, doing the call for fetching the worker would be done via custom ui code and a custom rest endpoint.

mlomo
Champ in-the-making
Champ in-the-making
Thanks. That was helpful. I've done some checking. Forgerock has a Rest API. This shows how I can access the endpoint with a curl command:

<code>
Mortens-iMacSmiley Surprisedpenidm Morten$ curl –header "X-OpenIDM-Username: openidm-admin" –header "X-OpenIDM-Password: openidm-admin" –request GET "http://localhost:8080/openidm/managed/tnsystem?_queryFilter=systemName+eq+'FHS'&_fields=rights" | jq .
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   221    0   221    0     0   5152      0 –:–:– –:–:– –:–:–  5261
{
  "result": [
    {
      "_id": "c2b89139-0ba0-4803-92a9-30416fbd9d37",
      "_rev": "1",
      "rights": "admin;readOnly"
    }
  ],
  "resultCount": 1,
  "pagedResultsCookie": null,
  "totalPagedResultsPolicy": "NONE",
  "totalPagedResults": -1,
  "remainingPagedResults": -1
}
</code>

But how do I access this endpoint from the form code (.xhtml) file?

Thanks for any help.
Morten