Uploaded image for project: 'PUBLIC - Liferay Portal Community Edition'
  1. PUBLIC - Liferay Portal Community Edition
  2. LPS-31981

Allow a user to assign a task to another user, in case of a workflow assignment by a groovy script

    Details

      Description

      Steps to reproduce:

      1. Create a site Kaleo
      2. Create a user reviewer1
      3. Assign user reviewer1
      4. Assign role Portal Content Reviewer to user reviewer1
      5. Create a user reviewer2
      6. Assign user reviewer2
      7. Assign role Portal Content Reviewer to user reviewer2
      8. Go to Control Panel > Configuration > Workflow Definition and upload definition workflowScript.xml with name "By script"
      9. Go to site Kaleo > Configuration > Workflow Configuration and set Workflow assignment-by-script to resource "Blogs Entry"
      10. Create a new Blog Entry
      11. Login as user reviewer 1
      12. Go to My Account > My Workflows Tasks

      Actual result:
      The available actions for the pending task are "Assign to me" and "Update Due Date"

      Expected result:
      The available actions for the pending task are "Assign to me", "Assign to ..." and "Update Due Date"

      Notes:
      To assign a task to another user is currently possible if the assignment is defined in the workflow definition's xml file.

      Example of the single-approver-definition.xml (from Kaleo):

      <assignments>
      <roles>
      <role>
      <role-type>organization</role-type>
      <name>Organization Owner</name>
      </role>
      <role>
      <role-type>regular</role-type>
      <name>Portal Content Reviewer</name>
      </role>
      <role>
      <role-type>site</role-type>
      <name>Site Owner</name>
      </role>
      </roles>
      </assignments>
      

      If the task assignment is rewritten to process a user data input:

      <assignments>
      <scripted-assignment>
      <script><![CDATA[// Script d'assignement du mail lors de l'assignement de la tâche.
      import com.liferay.portal.kernel.util.GetterUtil;
      import com.liferay.portal.kernel.workflow.WorkflowConstants;
      import com.liferay.portal.model.Role;
      import com.liferay.portal.service.RoleLocalServiceUtil;
      import com.liferay.portal.service.ServiceContext;
      import com.liferay.portlet.journal.model.JournalArticle;
      import com.liferay.portlet.journal.service.JournalArticleLocalServiceUtil;
      import com.liferay.portal.service.UserLocalServiceUtil;
      import com.choregie.util.GescoUtils;
      roles = new ArrayList<Role>();
      // Récupération du l'article en cours afin de récupérer le référent
      ServiceContext serviceContext = workflowContext.get(WorkflowConstants.CONTEXT_SERVICE_CONTEXT);
      String classPKJournalArticle = serviceContext.getAttribute("classPK");
      String referent = GescoUtils.getAssetReferent(serviceContext.getAttribute("className"),
      GetterUtil.getLong((String) classPKJournalArticle));
      if (referent != null && referent != "-1") {
      Role roleReferent = RoleLocalServiceUtil.getRole(Long.parseLong(referent));
      roles.add(roleReferent);
      } else {
      long companyId = GetterUtil.getLong((String)workflowContext.get(WorkflowConstants.CONTEXT_COMPANY_ID));
      Role roleResponsableSite = RoleLocalServiceUtil.getRole(companyId, "Responsable de Site");
      roles.add(roleResponsableSite);
      }
      user = null;]]>
      </script>
      <script-language>groovy</script-language>
      </scripted-assignment>
      </assignments>
      

      In the portlet « my_tasks » , there is no possibility to assign the task to another user.
      In the jsp file « workflow_task_action.jsp », the method getPooledActorsIds returns assignable users of a workflow task:

      long[]  pooledActorsIds  =  WorkflowTaskManagerUtil.getPooledActorsIds(company.getCompanyId(),workflowTask.getWorkflowTaskId());
      

      The method getPooledActorsIds (in com.liferay.portal.workflow.kaleo.WorkflowTaskManagerImpl) lists the assignment for the current task, only for the role type.

      List<KaleoTaskAssignment> kaleoTaskAssignments = KaleoTaskAssignmentLocalServiceUtil.getKaleoTaskAssignments(kaleoTask.getKaleoTaskId(), Role.class.getName());
      

      This method should list all the assignment types and (in case of assignment using a script) it should execute the groovy script to return the assignable users.

        Attachments

          Activity

            People

            Assignee:
            mark.jin Mark Jin (Inactive)
            Reporter:
            patricia.draut Patricia Draut
            Participants of an Issue:
            Recent user:
            Michael Wine
            Votes:
            2 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Days since last comment:
              6 years, 21 weeks, 1 day ago

                Packages

                Version Package
                7.0.0 M7