<select required
cam-variable-name="cmbApprover"
cam-variable-type="String"
ng-model="selectedUser"
ng-options="user as (user.firstName + ' ' + user.lastName) for user in users track by user.id">
</select>
Personally I don’t use cam-variable-* directives. Instead I use pure ng-model directive only and do variable manipulations utilizing javascript camForm.variableManager object as in below post
I added the following code snippet to my html form:
<div class="form-group">
<label for="userSelection" class="col-sm-2 control-label">User Selection</label>
<div class="col-sm-10">
<select required
cam-variable-name="cmbApprover"
cam-variable-type="String"
ng-model="selectedUser"
ng-options="user.id as (user.firstName + ' ' + user.lastName) for user in users">
</select>
<script cam-script type="text/form-script">
inject(['$scope', 'camAPI', function($scope, camAPI) {
var groupName = 'all-users';
var User = camAPI.resource('user');
User.list({memberOfGroup: groupName}, function(err, data) {
if (!err) {
alert('Data: ' + JSON.stringify(data));
$scope.users = data;
}
});
}]);
</script>
</div>
</div>
the user selction drop down remains empty. is there any error in my code?
Best Regards
Max
it returns an emtpy array. only “/user” returns all users or “/group” returns all user groups. this would be sufficient for my use case I guess. but how would I integrate this into my html form script ( in ng-model or ng-options) to have a dropdown of user groups for example ?
Then the code is working properly.
You need to change the filter of User.list so if your need is to get all users then replace the filter {memberOfGroup: groupName} with {}
thanks! I made it work like this - by creating an additional group allUsers which contains all users:
<div class="form-group">
<label for="userSelection" class="col-sm-2 control-label">additional Approver</label>
<div class="col-sm-10">
<select required
cam-variable-name="additionalApprover"
cam-variable-type="String"
ng-model="selectedUser"
ng-options="user.id as (user.firstName + ' ' + user.lastName) for user in users">
</select>
<script cam-script type="text/form-script">
inject(['$scope', 'camAPI', function($scope, camAPI) {
var groupName = 'allUsers';
var User = camAPI.resource('user');
User.list({memberOfGroup: groupName}, function(err, data) {
if (!err) {
alert('Data: ' + JSON.stringify(data));
$scope.users = data;
}
});
}]);
</script>
</div>
</div>
the question now is in the following user task I want to assign that user as assignee with ${additionalApprover} but it does not work as it returns a String and not the user itself. Do you know how to address the additional Approver correctly?
so in this example the user john is correctly taken over but it does not appear in his inbox as it is string:john. Do you know what to else to do with the variable “additionalApprover” to evaluate this as string…?
BR
MAx