Living Application: Display of list of tasks and the value of their variables

1
0
-1

Hi folks,
let's see if you have an idea for this.

I am building a living application. One container repeats over a collection.
I get that collection via API like this:
../API/bpm/activity?f=name=Artikel bewerten

(besides: How can I filter for only type=user_task?).

Now, for every activity that is returned, I want to retrieve an activity variable with a specific name ("test").
I've created an API call for that like this:
../API/bpm/activityVariable/{{ $item.id }}/test

I've put this API call into a variable called activityVars.
Inside of the first container (that displays the activities) I've inserted another one, that takes the activityVars as a collection.

Unfortunately, this doesn't work. Also a workaround with Javascript doesn't work ($item doesn't get iterated).

Any idea on how to solve this?

Thank you!
Valerio

PS: I thought of writing an REST API extension for his, but was hoping for a quicker solution

Comments

Submitted by Sean McP on Fri, 12/18/2015 - 17:23

Let me see...

you want a application that shows a list of processes and on selection shows you the current state of all variables for the process.

Just making sure...

regards

Submitted by valerioneri.de on Fri, 12/18/2015 - 18:45

Hi, thanks for the comment.
Not on selection, but as a list.

So having the Name of an Activity, and below or right from it the variable value.

I am generating task istances with a multi-instantiation and every task gets a variable filled with a value of a collection.

So I want the living application to show the variable next to the name.

The problem seems to be, that the API URL doesn't support $item.[param]

Thank you for your help

Submitted by valerioneri.de on Fri, 12/18/2015 - 19:00

Hmmm, your question has brought me to an "hack":
I'm writing the variable into the "description" of the task, like this I can get the value.

But it's not very "clean", it would be nicer if either, the Bonita API would return all variables upon the call (as a nested object) or if someone had some genious idea :)
Thanks

Submitted by Quentin Choulet on Mon, 12/21/2015 - 09:19

Hi,

$item is provided by the widget container and thus not available outside the scope of the container.

To avoid using a "hack" I would create a custom widget to retrieve and display the variable. If you want to make the widget generic, you can give it two parameters : the activity id and the variable name.

Regards

Submitted by valerioneri.de on Mon, 12/21/2015 - 09:46

Salut Quentin,
This sounds like a great idea! Thank you!
Best
Valerio

Ps: if you post it as answer, I'll mark it

1 answer

1
+1
-1
This one is the BEST answer!

Hi,

$item is provided by the widget container and thus not available outside the scope of the container.

To avoid using a "hack" I would create a custom widget to retrieve and display the variable. If you want to make the widget generic, you can give it two parameters : the activity id and the variable name.

Regards

Comments

Submitted by valerioneri.de on Mon, 12/21/2015 - 11:26

Thank you
This is how I solve it (or try: I don't get the value written back to the variable that is bound, maybe someone has an idea why?)

View
This gets shown

`<div>
    {{ theResult }}
</div>`

Controller
The linked variable resultingVariable doesn't get updated

`function ($scope, $http) {
    //  call the bonita API
    $http({
        method: 'GET',
        url: $scope.properties.APIUrl+$scope.properties.activityId+'/'+$scope.properties.variableName
    }).then( function successCallback(response) {
        console.dir($scope.resultingVariable);
        $scope.theResult = response.data;
        $scope.properties.resultingVariable = $scope.theResult;
    }, function errorCallback(response) {
    // no special error handling
        console.log('Custom Widget getActivityVariable Error');
        $scope.properties.resultingVariable = response;
    });
    `
Submitted by Quentin Choulet on Mon, 12/21/2015 - 11:33

Do you mean resultingVariable is not updated in your page ?

Submitted by valerioneri.de on Mon, 12/21/2015 - 11:34

Exactly, it just stays empty or with any starting value I give..

Submitted by Quentin Choulet on Mon, 12/21/2015 - 11:38

And the variable is displayed in your custom widget ?

Submitted by valerioneri.de on Mon, 12/21/2015 - 11:40

yes, the variable "theResult" gets displayed - I assume it has to do with scope synchronisation?
(unfortunately I'm new to AngularJS) - maybe with $scope.$apply?

*If this works, I'll package it and post it *

Submitted by Quentin Choulet on Mon, 12/21/2015 - 11:46

Normally you don't have to use $scope.$apply because the http callback is already handled is AngularJS digest cycle.

Just in case : do you have bind your widget property with the form variable ? Make sure you have checked the little link button on the right of the input. I often forget to check it and then search for hours why my variable isn't updated

Submitted by valerioneri.de on Mon, 12/21/2015 - 11:49

Hmmm I have it as a bidirectional bond, and it show the "binding" symbol -
In the variable editor the variable is of type JSON.

Submitted by valerioneri.de on Mon, 12/21/2015 - 13:03

Seems to have something to do with the asynchronous call to http - another test widget works
:? any ideas from the community?

Submitted by valerioneri.de on Mon, 12/21/2015 - 14:11

It's definitely a problem with asynchronous call - I'll post a new question for that...

Submitted by Quentin Choulet on Mon, 12/21/2015 - 14:15

Well I've run out of ideas, you should open a new thread to make your problem more visible.

Edit : Oops didn't see your last comment

Notifications