Living Application: Display of list of tasks and the value of their variables
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
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
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;
});
`
Exactly, it just stays empty or with any starting value I give..
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 *
Hmmm I have it as a bidirectional bond, and it show the "binding" symbol -
In the variable editor the variable is of type JSON.
Seems to have something to do with the asynchronous call to http - another test widget works
:? any ideas from the community?
It's definitely a problem with asynchronous call - I'll post a new question for that...
Comments
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
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
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
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
Salut Quentin,
This sounds like a great idea! Thank you!
Best
Valerio
Ps: if you post it as answer, I'll mark it