cancel
Showing results for 
Search instead for 
Did you mean: 

Completing a task and task history

tony1
Champ in-the-making
Champ in-the-making
Hi,

I have been searching the forum, and have found some answers, but i still can't resolve my problem.

The issue is next: i have to complete a task and submit its form data, and then, at some point, to get display that data as history. I am not using Activiti Explorer, i have just incorporated whole framework in my project, and i'm using its services. When i complete a task, all of its data is saved in ACT_HI_VARINST table, but in the column that should hold task id, i have nothing.

I am completing a task with:


@Resource(name = "taskService")
private TaskService taskService;

public void complete(String taskId, Map<String, Object> variables){
     taskService.complete(taskId, variables);
}


I have found the temporary solution though, with:



@Resource(name = "taskService")
private TaskService taskService;

public void complete(String taskId, Map<String, Object> variables){
     taskService.setVariablesLocal(taskId, variables);
     taskService.complete(taskId, variables);
}


but, this way i only get doubled rows in a database table, where one set of rows have the task id, and the other set of rows does not have a task id.

In my activiti.xml file, history is set to "full" as following:

<bean id="processEngineConfiguration" class="org.activiti.spring.SpringProcessEngineConfiguration">

      <property name="history" value="full" />

</bean>


I have also tried with:



@Resource(name = "formService")
private FormService formService;

public void complete(String taskId, Map<String, String> variables){
     formService.submitTaskFormData(taskId, variables);
}


but, with this, i also get saved data but without task id saved in a database table.

I am in need of help, and i'm gratefull of it.

Thank you,
7 REPLIES 7

tony1
Champ in-the-making
Champ in-the-making
I should point out that i am using 5.14 framework version.

frederikherema1
Star Contributor
Star Contributor
Completing a task and passing in variables (also when submitting a form) adds those variables to the execution/process-instance and NOT as a task-variable. Only variables set using setTaskLocal(..) or completeTask(id, vars, true) will be task-local and recorded with taskId in history:


/**
   * Called when the task is successfully executed,
   * and the required task paramaters are given by the end-user.
   * @param taskId the id of the task to complete, cannot be null.
   * @param variables task parameters. May be null or empty.
   * @param localScope If true, the provided variables will be stored task-local,
   *           instead of process instance wide (which is the default for {@link #complete(String, Map)}).
   * @throws ActivitiObjectNotFoundException when no task exists with the given id.
   */
  void complete(String taskId, Map<String, Object> variables, boolean localScope);

tony1
Champ in-the-making
Champ in-the-making
Hi Frederik,

I've looked up for that method, and it appears that i don't have it in my TaskService interface. How can it be possible that i don't have it?

Best regards,

jbarrez
Star Contributor
Star Contributor
If that's the case, it was most likely added to Activiti 5.15

tony1
Champ in-the-making
Champ in-the-making
Thank you very much for your help (both of You), i have updated activiti to 5.15 in my pom.xml file, updated my project, and now i have the above mentioned method. I think that there should be no problems.

Thank you very much again, i am very gratefull.

mghb2009
Champ in-the-making
Champ in-the-making
hi
i work with activiti 5.13
it's my code …
for start :
//—————————————————————————
if (isForm) {
                runtimeService.startProcessInstanceById(id_proc, map);
            } else {
                runtimeService.startProcessInstanceById(id_proc);
            }
//—————————————————————————
for complete and send to next user …

if (isForm) {
                taskService.complete(task_user.getId(), MapPropertyForm);

            } else {
                taskService.complete(task_user.getId());
            }

form Properties saved in act_hi_varinst table and taskId is null !!!
when use this:
formService.submitTaskFormData(taskId, variables);
Stored but not send to next user!
what is my problem?

mghb2009
Champ in-the-making
Champ in-the-making
when and where use these ?
taskService.complete
formService.submitTaskFormData
taskService.setVariablesLocal
and if the other codes are … !!!