Hello,
I created a groovy script in order to get users has a specific role in a specific group.
I set the actor with groovy script
import org.bonitasoft.engine.api.IdentityAPI;
import org.bonitasoft.engine.identity.Group;
import org.bonitasoft.engine.identity.GroupCriterion;
import org.bonitasoft.engine.identity.User;
import org.bonitasoft.engine.search.SearchOptionsBuilder
import org.bonitasoft.engine.search.SearchResult
import org.bonitasoft.engine.identity.UserCriterion;
import org.bonitasoft.engine.identity.UserMembership;
import org.bonitasoft.engine.identity.UserMembershipCriterion;
import org.bonitasoft.engine.identity.UserSearchDescriptor;
IdentityAPI identity = apiAccessor.getIdentityAPI();
long specificRoleId=apiAccessor.identityAPI.getRoleByName("approver").getId();
final SearchOptionsBuilder builder = new SearchOptionsBuilder(0, 100);
builder.filter(UserSearchDescriptor.GROUP_ID, department);
builder.filter(UserSearchDescriptor.ROLE_ID, specificRoleId);
final SearchResult<User> userResults = apiAccessor.identityAPI.searchUsers(builder.done());
List<Long> reviewerList = new ArrayList<Long>();
for(User user:userResults.getResult()){
reviewerList.add(user.getId())
}
return reviewerList;
The result value is like :
"value": [ 513, 521 ],
However, I got the error.
Caused by: org.bonitasoft.engine.core.filter.exception.SUserFilterExecutionException: org.bonitasoft.engine.expression.exception.SExpressionEvaluationException: FLOW_NODE_INSTANCE_ID=1400397 | Declared return type class java.lang.Long is not compatible with evaluated type class java.util.ArrayList for expression userId()
at org.bonitasoft.engine.core.filter.impl.UserFilterServiceImpl.executeFilter(UserFilterServiceImpl.java:131)
at org.bonitasoft.engine.userfilter.UserFilterServiceDecorator.executeFilter(UserFilterServiceDecorator.java:68)
at org.bonitasoft.engine.execution.StateBehaviors.mapUsingUserFilters(StateBehaviors.java:315)
at org.bonitasoft.engine.execution.StateBehaviors.mapActors(StateBehaviors.java:287)
... 21 more
Caused by: org.bonitasoft.engine.expression.exception.SExpressionEvaluationException: FLOW_NODE_INSTANCE_ID=1400397 | Declared return type class java.lang.Long is not compatible with evaluated type class java.util.ArrayList for expression userId()
at org.bonitasoft.engine.expression.impl.ReturnTypeChecker.checkReturnType(ReturnTypeChecker.java:53)
at org.bonitasoft.engine.expression.impl.ExpressionServiceImpl.evaluate(ExpressionServiceImpl.java:94)
at org.bonitasoft.engine.core.expression.control.api.impl.ExpressionResolverServiceImpl.evaluateExpressionWithResolvedDependencies(ExpressionResolverServiceImpl.java:213)
at org.bonitasoft.engine.core.expression.control.api.impl.ExpressionResolverServiceImpl.evaluateExpressionsFlatten(ExpressionResolverServiceImpl.java:120)
at org.bonitasoft.engine.core.expression.control.api.impl.ExpressionResolverServiceImpl.evaluate(ExpressionResolverServiceImpl.java:83)
at org.bonitasoft.engine.core.filter.impl.UserFilterServiceImpl.executeFilterInClassloader(UserFilterServiceImpl.java:206)
at org.bonitasoft.engine.core.filter.impl.UserFilterServiceImpl.executeFilter(UserFilterServiceImpl.java:116)
... 24 more
I do not get the reason why.
Any help would be appreciated .
Thanks in advanced.