Hi @all,
I searched for days in different forums and the documentation, but can’t find a hint to list all users of a group in the cam-script directive of a custom embedded form to use them f.e. as cam-choice variable inside
Hi @all,
I searched for days in different forums and the documentation, but can’t find a hint to list all users of a group in the cam-script directive of a custom embedded form to use them f.e. as cam-choice variable inside
@ svogel - Can you try by setting the “aync before” on the start shape and see if it works .
The same result, unfortunately. I think I can not read gloabl variables, I set during the same task.
But thank you for the answer.
Hi @svogel,
depending on the type of form, you can use the REST Api to query for users: https://docs.camunda.org/manual/7.12/reference/rest/user/get-query/
Hope this helps, Ingo
Hi,
I had the same issue and searched some hours to find the solution, how to create a selectable user list in an embedded form:
List<User> userList = execution.getProcessEngineServices().getIdentityService().createUserQuery().memberOfGroup("user-group-id").list(); ObjectValue customerDataValue = Variables.objectValue(userList) .serializationDataFormat(Variables.SerializationDataFormats.JSON) .create(); execution.setVariable("users", customerDataValue);
Attention: You have to call the Listener before your Task where the embedded form is, because the embedded form will be called before your Listener.
To use the ObjectValue correclty, you will have to integrate org.camunda.spin in your project. Camunda offers a good description for this.
<div> <label for="selected_user">Choose your Gefa leader</label> <script cam-script type="text/form-script"> camForm.on('form-loaded', function() { camForm.variableManager.fetchVariable('users'); }); camForm.on('variables-fetched', function() { $scope.gefaLeaders = camForm.variableManager.variableValue('users'); }); </script> <select cam-variable-name="selected_user" cam-variable-type="String" ng-options="c as c.id for c in users track by c"> </select> </div>
And thats it. Following these steps I was able to select users from a drop down list.
I hope this helps.
I had the same issue and @MarvinKern solution didn’t work for me because I am not using Java in my project and couldn’t integrate spin in my project.
I am beginner in HTML and Javascript, but I got answers for many from many topics in this forum and with trial and error I got a working solution without a task listener, using only the REST API.
<div>
<script cam-script type="text/form-script">
inject(['$http', 'Uri', function($http, Uri) {
camForm.on('form-loaded', function() {
$http.get(Uri.appUri("engine://engine/:engine/user?memberOfGroup=" + "YOURUSERGROUP")).then(function(result) {
let candidates = [];
for (let user of result.data) {
candidates.push({
id: user.id,
name: user.firstName + " " + user.lastName
});
}
$scope.group_candidates = candidates;
});
});
}]);
</script>
<label>Who will execute the request? </label>
<div>
<select cam-variable-name="task_owner"
cam-variable-type="String"
ng-options="c.name for c in group_candidates track by c.id"
required
class="form-control">
</select>
</div>
</div>