Access HistoryService from Javascript?

Ok guys here is how I solved it.
Probably not the most elegant solution ever seen, but I’m not familar with AngularJS at all…

inject([ '$scope', 'camAPI', '$http', function($scope, camAPI, $http) {
	$scope.displayFinishedProcessInstances = function () {
			var History = camAPI.resource('history');
			
			History.processInstance({finished: true, processDefinitionKey:'onboarding'}, function(err, data) {
				if (!err) {

					angular.forEach(data, function(pi) {
						 alert("Found a finished process instance with id: " + pi.id);

						var lastName;
						
                                                    // ACCESS THE HISTORIC VARIABLE INFORMATION
						$http.get('/camunda/api/engine/engine/default/history/variable-instance',
							{ params: {
								processInstanceId : pi.id,
								variableName : 'my_var_name'
								}
							}).
					                success(function(data) {
								
        						           lastName = data[0].value;

					        
				}
			});
		};
}]);
1 Like