workflow error
I am creating a workflow to assign the role to the user at community and domain level. But I am getting the below error.
Params: [role_assigment]
Message: org.flowable.common.engine.api.FlowableException: problem evaluating script: javax.script.ScriptException: java.lang.NullPointerException: Cannot invoke method getRole() on null object
at com.collibra.dgc.core.workflow.activiti.WorkflowEngineImpl.lambda$createProcessInstanceExecutor$6(WorkflowEngineImpl.java:488)
at com.collibra.dgc.core.workflow.activiti.WorkflowExceptionHandler$Executor.execute(WorkflowExceptionHandler.java:188)
at com.collibra.dgc.core.workflow.activiti.WorkflowEngineImpl.startProcessTemplate(WorkflowEngineImpl.java:458)
The below mentioned script task,
import com.collibra.dgc.core.api.dto.MatchMode
import com.collibra.dgc.core.api.dto.role.FindRolesRequest
import com.collibra.dgc.core.api.dto.user.FindUsersRequest
import com.collibra.dgc.core.api.dto.instance.asset.SetAssetResponsibilitiesRequest
import com.collibra.dgc.core.api.dto.usergroup.FindUserGroupsRequest
import com.collibra.dgc.core.api.model.role.Role
import com.collibra.dgc.core.api.dto.instance.responsibility.AddResponsibilityRequest
import com.collibra.dgc.core.api.model.user.User
import com.collibra.dgc.core.api.model.usergroup.UserGroup
originalUserObj = userApi.getUserByUsername(user_id)
execution.setVariable(“originalUserId”, originalUserObj.getId())
Role reviewerRole
List foundRoles = roleApi.findRoles(FindRolesRequest.builder().name(“Reviewer”).nameMatchMode(MatchMode.EXACT).build()).getResults()
if (!foundRoles.isEmpty()) {
reviewerRole = foundRoles.get(0)
}
responsibilityApi.addResponsibility(AddResponsibilityRequest.builder()
arthurburkhardt
·3 years ago · Editedwhew, quite some issues to unpack. Coaching would probably the best way to go.
I had a quick glance, here are some obvious problems: community_id is a UUID, but you use it as a name, cast to a string (with a leading space???), try to fetch an “id” property from that string, then pass an array instead of a UUID to the AddResponsibilityRequest.
That… that won’t work.
If I can find 5 issues in less than 30 seconds, I would say there are probably other issues with the code.
I would recommend to:
ankursingh1
OP3 years ago · Edited@arthur.burkhardt I am attaching the cod e. There is issue with add responsibility code. I am fetching the user community and role details from the dropdown list. Could you please check and help me for the same.role.txt (9.8 KB)
arthurburkhardt
·3 years ago · EditedSorry, difficult to read your code because of formatting. Can you please use proper markdown formatting?
Will result in
Role reviewerRole List foundRoles = roleApi.findRoles(FindRolesRequest.builder() .name([role_Id]) .nameMatchMode(MatchMode.EXACT) .build()).getResults()ankursingh1
OP3 years ago · Edited@arthur.burkhardt I am using the drop down list. to get the user name , role and community.
Using the below code to get the user id details its is working…
originalUserObj = userApi.getUserByUsername(user_id)
USing this code to fetch the role details. It also working
Role reviewerRole
List foundRoles = roleApi.findRoles(FindRolesRequest.builder().name([role_Id]).nameMatchMode(MatchMode.EXACT).build()).getResults()
====
using the below code to get community details… Its also working used the logger
communitySearch = communityApi.findCommunities(FindCommunitiesRequest.builder().name(community_id).nameMatchMode(MatchMode.END).limit(10000).build()).getResults()
Now issue with the code
addResponsibilitiesList = []
addResponsibilitiesList.add(responsibilityApi.addResponsibility(AddResponsibilityRequest.builder()
.ownerId(userApi.getUserByUsername(user_id).getId())
.resourceId(userCommunityId)
.resourceType(userCommunityName)
.roleId(getRolId(role ) )
.build()))
}
getting below error–
Params: [role_assigment]
Message: org.flowable.common.engine.api.FlowableException: problem evaluating script: javax.script.ScriptException: groovy.lang.MissingMethodException: No signature of method: java.lang.String.getId() is applicable for argument types: () values: []
Possible solutions: getAt(int), getAt(groovy.lang.IntRange), getAt(groovy.lang.EmptyRange), getAt(groovy.lang.IntRange), getAt(groovy.lang.Range), getAt(groovy.lang.Range)
================

arthurburkhardt
·3 years ago · Edited@ankur.singh1.genpact.com
You should not look up the role ID, you should define it in your startForm:
Also, you code will fail if the role “Reviewer” is not found (e.g. renamed).
But your code should run with