cancel
Showing results for 
Search instead for 
Did you mean: 

Regarding assigning candidate group for use task dynamically

indrayani
Champ in-the-making
Champ in-the-making
Hi,

I am running activiti from liferay.
I am trying to set candidate group for user task dynamically for which I have tried below solutions which are not working.
This is for liferay 6.2 CE GA6 and activiti version 5.18.0
Please let me know if I have missed anything or If you have a better solution.

Solution 1 :
Its regarding settting candidate group for a user task using proccess variable.
below is the bpmn code :

  <userTask id="Review" name="Review"  activiti:candidateGroups=${assignee}>
      <extensionElements>
        <activiti:formProperty id="outputTransition" name="output Transition" type="enum">
          <activiti:value id="Approve" name="Approve"></activiti:value>
          <activiti:value id="Reject" name="Reject"></activiti:value>
        </activiti:formProperty>
      </extensionElements>
    </userTask>

here , assignee is the process variable which is already set.

While executing the workflow, I am getting following exception :

13:42:01,326 INFO  [http-bio-8080-exec-10][LiferayGroupsUtil:54] Convert groups : [ ${assignee} ]
13:42:01,329 WARN  [http-bio-8080-exec-10][LiferayGroupsUtil:94] Cannot assign task to role ${assignee}
com.liferay.portal.NoSuchRoleException: No Role exists with the key {companyId=20155, name=${assignee}}


——————————————————————————————
Solution 2 :

I also tried below xml code but I am still getting the same exception :
Here, I have the multiInstanceLoopCharacteristics.
 
<userTask id="Review" name="Review"  activiti:candidateGroups=${assignee}>
       <multiInstanceLoopCharacteristics isSequential="false"
        activiti:collection="candidateGrp" activiti:elementVariable="assignee" >
       <completionCondition>${nrOfCompletedInstances/nrOfInstances >= 0.6 }</completionCondition>
     </multiInstanceLoopCharacteristics>
      <extensionElements>
        <activiti:formProperty id="outputTransition" name="output Transition" type="enum">
          <activiti:value id="Approve" name="Approve"></activiti:value>
          <activiti:value id="Reject" name="Reject"></activiti:value>
        </activiti:formProperty>
      </extensionElements>
    </userTask>

——————————————————————————————
Solution 3:

I also tried to set the candidate group dynmically using DynamicBpmnService, Please check the code below :
For this approach, I used activiti version 5.19.0
I replaced the activiti engine jar from liferay > tomcat> webapp > activiti-web > web-inf >lib
          

       @Override
   public void notify(DelegateExecution execution) {
      try {
      EngineServices engineServices = execution.getEngineServices();
      DynamicBpmnService dynamicBpmnService = engineServices.getDynamicBpmnService();
      ObjectNode infoNode = dynamicBpmnService.changeUserTaskCandidateGroup(
               "Review", "Power User", false);
      dynamicBpmnService.saveProcessDefinitionInfo("procDefId", infoNode);
      System.out.println("——saveProcessDefinitionInfo——=saved");
      
      } catch (Exception e) {
         System.out.println("——error");
         e.printStackTrace();
      }
      List<String> list = new ArrayList<String>();
      list.add("Power User");
      execution.setVariable("candidateGrp",list);
   }

I am getting following exception while executing this code :

WARN  [http-bio-8080-exec-10][ProxyMessageListener:81] org.apache.ibatis.exceptions.PersistenceException:
### Error updating database.  Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Cannot add or update a child row: a foreign key constraint fails (`lportal`.`act_procdef_info`, CONSTRAINT `ACT_FK_INFO_PROCDEF` FOREIGN KEY (`PROC_DEF_ID_`) REFERENCES `act_re_procdef` (`ID_`))
### The error may involve org.activiti.engine.impl.persistence.entity.ProcessDefinitionInfoEntity.insertProcessDefinitionInfo-Inline
### The error occurred while setting parameters
### SQL: insert into ACT_PROCDEF_INFO(ID_, PROC_DEF_ID_, REV_, INFO_JSON_ID_)     values(?,             ?,            1,            ?)
### Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Cannot add or update a child row: a foreign key constraint fails (`lportal`.`act_procdef_info`, CONSTRAINT `ACT_FK_INFO_PROCDEF` FOREIGN KEY (`PROC_DEF_ID_`) REFERENCES `act_re_procdef` (`ID_`))
org.apache.ibatis.exceptions.PersistenceException:
### Error updating database.  Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Cannot add or update a child row: a foreign key constraint fails (`lportal`.`act_procdef_info`, CONSTRAINT `ACT_FK_INFO_PROCDEF` FOREIGN KEY (`PROC_DEF_ID_`) REFERENCES `act_re_procdef` (`ID_`))
### The error may involve org.activiti.engine.impl.persistence.entity.ProcessDefinitionInfoEntity.insertProcessDefinitionInfo-Inline
### The error occurred while setting parameters
### SQL: insert into ACT_PROCDEF_INFO(ID_, PROC_DEF_ID_, REV_, INFO_JSON_ID_)     values(?,             ?,            1,            ?)
### Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Cannot add or update a child row: a foreign key constraint fails (`lportal`.`act_procdef_info`, CONSTRAINT `ACT_FK_INFO_PROCDEF` FOREIGN KEY (`PROC_DEF_ID_`) REFERENCES `act_re_procdef` (`ID_`))



Thank you,
Indrayani
3 REPLIES 3

indrayani
Champ in-the-making
Champ in-the-making
Hi,

I am really stuck at this point and have spent descent amount of time in figuring out what is going wrong in the code but had no luck.
So your quick help would be appreciated.

Best Regards,
Indrayani

mrc0mm0n
Champ in-the-making
Champ in-the-making
Hi Indrayani,

I'm using 6.2 CE GA6 and Activiti 5.22.0. This is what I have been able to get so far.

- Candidate groups of Activiti maps to User Roles in Liferay. Can't upload images here, so I'll try to describe this best.

Start -> Site A - Group 1(UserTask) -> EG1 -> Yes -> Site A - Group 2(UserTask) -> EG2-> Yes -> Site A - Group 3(UserTask) -> EG3 -> Yes -> End

EG1 -> No -> Site A - Group 1(UserTask)
EG2 -> No -> Site A - Group 1(UserTask)
EG3 -> No -> Site A - Group 1(UserTask)

EG: Exclusive Gateway

- I logged in as Joe(Admin) user and in the Workflow -> Subbmissions Tab, each of the accordion will show the respective pieces.
- And the logs will say the below.

12:07:18,484 INFO  [IdMappingService:38] Activiti user name strategy: userId
12:11:51,849 INFO  [LiferayGroupsUtil:54] Convert groups : [ Site A - Reviewer Role C ]
12:11:51,872 INFO  [LiferayGroupsUtil:99] Converted to 21303/Site A - Reviewer Role C
12:11:52,357 INFO  [WorkflowTaskManagerImpl:213] There is no next task to user 20198
12:12:24,381 INFO  [LiferayGroupsUtil:54] Convert groups : [ Site A - Reviewer Role A ]
12:12:24,383 INFO  [LiferayGroupsUtil:99] Converted to 21303/Site A - Reviewer Role A
12:12:24,855 INFO  [WorkflowTaskManagerImpl:213] There is no next task to user 20198
12:28:44,498 INFO  [LiferayGroupsUtil:54] Convert groups : [ Site A - Reviewer Role B ]
12:28:44,511 INFO  [LiferayGroupsUtil:99] Converted to 21303/Site A - Reviewer Role B
12:28:45,251 INFO  [WorkflowTaskManagerImpl:213] There is no next task to user 20198

FYI, It's been a month I started using LR 6.2 CE GA6 and Activiti 5.22. I'm trying to join the pieces myself. Let me know If I've put up any misleading info.

jbarrez
Star Contributor
Star Contributor
> com.liferay.portal.NoSuchRoleException: No Role exists with the key {companyId=20155, name=${assignee}}

This does looks like a liferay exception … I don't believe many people here will be able to help you.