AnsweredAssumed Answered

How can I delete a task?

Question asked by Aleksey Bykov on Dec 10, 2017
Latest reply on Dec 11, 2017 by Aleksey Bykov

Or more precisely - is there a way to remove a participant from subsequent iterations if it was "deleted" at the first iteration? 

 

What I mean...

 

For example, there is a some parallel workflow. I choose 10 participants and initiated this business process. Thus, 10 tasks were created, one for each participant. But then I decided to delete a few participants.

 

I can to complete these tasks by using WebScript. For example, as follows. I know the workflowId and taskId:

...
Map<String, String> templateArgs = req.getServiceMatch().getTemplateVars();

// String workflowId = templateArgs.get("workflowId");
String taskId = templateArgs.get("taskId");

Map<QName, Serializable> updatedProperties = new HashMap<>();
updatedProperties.put(TaskRemoverModel.REVIEW_OUTCOME_PROPERTY, "Approve");    
updatedProperties.put(TaskRemoverModel.COMMENT_PROPERTY,
     "The user was excluded from the list of participants.");

workflowService.updateTask(taskId, updatedProperties, null, null);
workflowService.endTask(taskId, null);
...

 

But the problem is that at the stage of revise, the initiator can send for approval again. Then tasks for excluded participants will be created again.

 

Is there a way to "mark" these participants, so that no tasks were created for them in the future?

 

For example, in the WebScript I added a new property to the task that should not be generated after resubmited.

...
updatedProperties.put(TaskRemoverModel.TASK_WAS_EXCLUDED_SIGN, "exclude");

workflowService.updateTask(taskId, updatedProperties, null, null);
workflowService.endTask(taskId, null);
...

 

Where:

 

...
public static final String BPM_MODEL_URI = "http://www.alfresco.org/model/bpm/1.0";
public static final QName TASK_WAS_EXCLUDED_SIGN = QName.createQName(BPM_MODEL_URI, "taskWasExcluded");
...

 

In the listener that listens for the complete event for a task, I can get the following set of variables:

 

public class TaskCompleteListener implements TaskListener {
     ...
     public void notify(DelegateTask delegateTask) {

          Map<String, Object> exVars = execution.getVariables();
          Iterator iterator = exVars.entrySet().iterator();
          while(iterator.hasNext()) {
               Map.Entry exVar = (Map.Entry)iterator.next();
               if(exVar.getKey() != null) {
                    System.out.println("var == " +
                         exVar.getKey().toString() + ",
                    value == " + exVar.getValue());
               }
          }
     ...
     }
}

 

I get the following:

 

var == bpm_packageActionGroup, value == add_package_item_actions
var == bpm_reassignable, value == true
var == tkbwf_reviewerCount, value == 4.0
var == bpm_priority, value == 2
var == initiator, value == Node Type: {http://www.alfresco.org/model/content/1.0}person, Node Aspects: [{http://www.alfresco.org/model/content/1.0}ownable, {http://www.alfresco.org/model/system/1.0}referenceable, {http://www.alfresco.org/model/system/1.0}localized, {http://www.alfresco.org/model/content/1.0}preferences]
var == bpm_sendEMailNotifications, value == false
var == bpm_percentComplete, value == 0
var == tkbwf_rejectCount, value == 0.0
var == workflowinstanceid, value == activiti$4806
var == bpm_hiddenTransitions, value ==
var == bpm_workflowPriority, value == 2
var == bpm_workflowDueDate, value == null
var == bpm_package, value == Node Type: {http://www.alfresco.org/model/bpm/1.0}package, Node Aspects: [{http://www.alfresco.org/model/bpm/1.0}workflowPackage, {http://www.alfresco.org/model/content/1.0}auditable, {http://www.alfresco.org/model/system/1.0}referenceable, {http://www.alfresco.org/model/system/1.0}localized]
var == tkbwf_approveCount, value == 1.0
var == tkbwf_tpApproved, value == false
var == nrOfActiveInstances, value == 4
var == bpm_workflowDescription, value == Another check
var == bpm_packageItemActionGroup, value == start_package_item_actions
var == _startTaskCompleted, value == Mon Dec 11 19:26:58 GMT+04:00 2017
var == companyhome, value == Node Type: {http://www.alfresco.org/model/content/1.0}folder, Node Aspects: [{http://www.alfresco.org/model/content/1.0}titled, {http://www.alfresco.org/model/content/1.0}auditable, {http://www.alfresco.org/model/system/1.0}referenceable, {http://www.alfresco.org/model/system/1.0}localized, {http://www.alfresco.org/model/application/1.0}uifacets]
var == tkbwf_package, value == null
var == bpm_assignees, value == [Node Type: {http://www.alfresco.org/model/content/1.0}person, Node Aspects: [{http://www.alfresco.org/model/content/1.0}ownable, {http://www.alfresco.org/model/system/1.0}referenceable, {http://www.alfresco.org/model/system/1.0}localized, {http://www.alfresco.org/model/content/1.0}preferences], Node Type: {http://www.alfresco.org/model/content/1.0}person, Node Aspects: [{http://www.alfresco.org/model/content/1.0}ownable, {http://www.alfresco.org/model/system/1.0}referenceable, {http://www.alfresco.org/model/system/1.0}localized], Node Type: {http://www.alfresco.org/model/content/1.0}person, Node Aspects: [{http://www.alfresco.org/model/content/1.0}ownable, {http://www.alfresco.org/model/system/1.0}referenceable, {http://www.alfresco.org/model/system/1.0}localized], Node Type: {http://www.alfresco.org/model/content/1.0}person, Node Aspects: [{http://www.alfresco.org/model/content/1.0}ownable, {http://www.alfresco.org/model/system/1.0}referenceable, {http://www.alfresco.org/model/system/1.0}localized]]
var == loopCounter, value == 1
var == bpm_description, value == Another check
var == nrOfInstances, value == 4
var == initiatorhome, value == Node Type: {http://www.alfresco.org/model/content/1.0}folder, Node Aspects: [{http://www.alfresco.org/model/content/1.0}titled, {http://www.alfresco.org/model/content/1.0}auditable, {http://www.alfresco.org/model/system/1.0}referenceable, {http://www.alfresco.org/model/system/1.0}localized, {http://www.alfresco.org/model/application/1.0}uifacets]
var == cancelled, value == false
var == bpm_comment, value ==
var == bpm_status, value == Not Yet Started
var == reviewAssignee, value == Node Type: {http://www.alfresco.org/model/content/1.0}person, Node Aspects: [{http://www.alfresco.org/model/content/1.0}ownable, {http://www.alfresco.org/model/system/1.0}referenceable, {http://www.alfresco.org/model/system/1.0}localized]
var == nrOfCompletedInstances, value == 0

 

As far as I understand, I need this pair (for example, I assigned 4 participants), but there are no references to the nodes:

var == bpm_assignees, 
value ==
     [Node Type:
          {http://www.alfresco.org/model/content/1.0}person,
          Node Aspects:
               [{http://www.alfresco.org/model/content/1.0}ownable,
               {http://www.alfresco.org/model/system/1.0}referenceable,
               {http://www.alfresco.org/model/system/1.0}localized,
               {http://www.alfresco.org/model/content/1.0}preferences],
     Node Type:
          {http://www.alfresco.org/model/content/1.0}person,
          Node Aspects:
               [{http://www.alfresco.org/model/content/1.0}ownable,
               {http://www.alfresco.org/model/system/1.0}referenceable,
               {http://www.alfresco.org/model/system/1.0}localized],
     Node Type:
          {http://www.alfresco.org/model/content/1.0}person,
          Node Aspects:
               [{http://www.alfresco.org/model/content/1.0}ownable,
               {http://www.alfresco.org/model/system/1.0}referenceable,
               {http://www.alfresco.org/model/system/1.0}localized],
     Node Type:
          {http://www.alfresco.org/model/content/1.0}person,
          Node Aspects:
               [{http://www.alfresco.org/model/content/1.0}ownable,
               {http://www.alfresco.org/model/system/1.0}referenceable,
               {http://www.alfresco.org/model/system/1.0}localized]
     ]

 

In the task properties by using the WorkflowService I can find the following sequence:

 

key == {http://www.alfresco.org/model/bpm/1.0}assignees, 
value == [workspace://SpacesStore/bf7db7b8-5678-4481-9131-3ee7ae062a27,
       workspace://SpacesStore/5e6dad71-fc14-420f-a038-180d8bebf45c,
       workspace://SpacesStore/f1f5f39d-289c-4a56-9cfb-0790535b3a31,
       workspace://SpacesStore/84237c79-d2a6-408a-9837-8a55697e83f8
]

 

Can I assume that these sequences coincide? For example, I deleted the participant with:

 

nodeRef == workspace://SpacesStore/5e6dad71-fc14-420f-a038-180d8bebf45c 

 

(second in the list). Then I should delete the second value in the first list:

Node Type: 
     {http://www.alfresco.org/model/content/1.0}person,
Node Aspects:
     [{http://www.alfresco.org/model/content/1.0}ownable,
     {http://www.alfresco.org/model/system/1.0}referenceable,
     {http://www.alfresco.org/model/system/1.0}localized],

 

Is this the right approach?...

 

I would be very grateful for the information. Thanks to all.

Outcomes