Variable doesn't get updated if custom widget uses asynchronous call (REST)

1
0
-1

Hi,
I've built a custom widget (thanks to quentin ) that retrieves a variable from an activity, by using Bonita REST API.
The variable is displayed by the widget, but I want it to write that value into a variable defined in the editor.

So I did a bidirectional binding. The variable never gets updated. By testing, I found out that the problem seems to lye in the asynchronous call. I've tried several things ($scope.$apply, variable = return $http...) but did not succeed.

Any ideas?
Here is the controller code:

` function ($scope, $http) {
// call the bonita API
$scope.theResult = '';
$scope.properties.resultingVariable = $scope.theResult;
$http.get($scope.properties.APIUrl+$scope.properties.activityId+'/'+$scope.properties.variableName).then(
function successCallback(response) {
$scope.theResult = response.data[$scope.properties.propertyToDisplay];
console.log('hello');
$scope.properties.resultingVariable = response.data;
}
);
}

}`

And the model

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

resultingVariable is a "bidirectional bond".

Thank you!
Valerio

Comments

Submitted by Quentin Choulet on Tue, 12/22/2015 - 11:32

Can you export the custom widget and upload it somewhere ? It will be easier to find a solution if I can experiment with the widget

Regards

Submitted by valerioneri.de on Tue, 12/22/2015 - 15:26
Submitted by Quentin Choulet on Wed, 12/23/2015 - 11:40

I took a look at your widget but I can't see what's wrong, sorry. Maybe the problem comes from your page

Submitted by valerioneri.de on Wed, 12/23/2015 - 12:25

Hi Quentin, it means that in your experiment the variable you set into the binding is updated?
Ok I'll need to check that, quite odd...

Submitted by valerioneri.de on Wed, 12/23/2015 - 12:25

Hi Quentin, it means that in your experiment the variable you set into the binding is updated?
Ok I'll need to check that, quite odd...

Submitted by Quentin Choulet on Wed, 12/23/2015 - 12:32

Yes, I did a really quick test with a single task process and it worked

Submitted by valerioneri.de on Wed, 12/23/2015 - 12:33

You're right, it works - seems to be something with the page!

1 answer

1
0
-1
This one is the BEST answer!

It works - I'll upload the custom widget as a new project

Notifications