How to pass result of json from rest enquiry to html select control in start form

257 views
Skip to first unread message

GaryRich

unread,
Oct 23, 2015, 12:16:33 PM10/23/15
to camunda BPM users
Hi,

I am new to Camunda and AngularJS and am struggling to populate a dropdown/select on a start form with dynamic data.

I found another post on this forum which said the normal method of populating selects won't work because when this form is fist shown the process hasn't begun yet.

So I was trying to get a script in the html form to get the select options by calling a rest servlet which returns json.

This seems to be working as I can display the returned data in a javascript alert. But I am not struggling to figure out how to pass this on to the "cam-choices" attribute of my select.

Is anyone able assist or recommend a suitable example.

Code is as follows:


<form cam-form role="form">

<script cam-script type="text/form-script">

inject([ '$scope', '$http', function($scope, $http) {
camForm.on('form-loaded', function() {


$http({
method: 'GET',
url: 'http://w7-develop2:8080/ServletTest/JsonServlet?q=XXX%20YYY%20ZZZ'
}).then(
function successCallback(response)
{
alert('SUCCESS :-) ' + angular.toJson(response.data));
$scope.data = response.data
},
function errorCallback(response) {
alert('FAILED :-( ' + response.status);
});

});
}]);

</script>


<div class="form-group">
<select cam-variable-name="companyId"
cam-variable-type="String"
cam-choices="{{data}}">>
</select>
</div>

Thanks in advance for any assistance

Roman Smirnov

unread,
Oct 26, 2015, 5:17:53 AM10/26/15
to camunda BPM users, ruthmar...@gmail.com
Hi Gary,

Have you tried to use the angularjs directive ng-options [1] instead of "cam-choices"?

Cheers,
Romn

Reply all
Reply to author
Forward
0 new messages