cancel
Showing results for 
Search instead for 
Did you mean: 

how to update task variables of completed workflow tasks

nagarajut8
Champ in-the-making
Champ in-the-making
Hi All,

I trying to update the task variables which are related to completed workflow tasks. Please provide any valuable suggestions for this

Thanks,
Nagaraju.
7 REPLIES 7

martin_grofcik
Confirmed Champ
Confirmed Champ
Hi Nagaraju,

already completed tasks can not be updated in runtime tables. (They do not exist already.) You can try to update history tables. From my point of view making changes in the history does not make sense.
Could you provide jUnit test what are you trying to do?

Regards
Martin

nagarajut8
Champ in-the-making
Champ in-the-making
Thanks for the reply.
we are developing workflow history component for all workflows which are completed or in progress state, currently with in workflow history component we need to show some audit information, as of now we are getting values from audit tables and shown in workflow history component. instead doing like that we are thinking to get values from audit tables and set to task properties to improve performance of workflow history component.

Thanks,
Nagaraju.

martin_grofcik
Confirmed Champ
Confirmed Champ
Hi Nagaraju.

I did not catch the idea why you want to store historic data in task properties. From my point of view audit trail info does not belong to task properties. If you need more detailed audit trail info or store audit trail differently, use beats and your own way of storing audit trail data.
Regards
Martin

nagarajut8
Champ in-the-making
Champ in-the-making
Thanks for your valuable suggestions, we are thinking to optimize performance of application by reducing the number of calls to server, as of now we are using separate services for getting workflow task related information those are initiated on document  and audit information related to same document for showing entire history of document in one place. in that case we are thinking to save document properties in workflow task instead of audit trails for reducing calls and improve performance.
As discussed above we already saving document related properties in task properties instead of audit trails for in-progress tasks and newly initiated workflows,we are unable to update properties related to completed tasks.
Please let us know if there is any possibility to update the property for completed tasks.

Thanks,
Nagaraju

jbarrez
Star Contributor
Star Contributor
Historic variables are not updateable through the API. The audit trail is fixed and should not be changed.
If you want to do so, you can of course have custom logic that allows updating the variables. You would need a custom command for that and maybe custom sql (http://www.jorambarrez.be/blog/2014/01/17/execute-custom-sql-in-activiti/).

ndogra
Champ in-the-making
Champ in-the-making
Hi,

I am trying to use a custom mapper for updating the histroic variables. Here's the mapper code

interface CustomActivitiMapper {

    @Update("UPDATE ACT_HI_VARINST SET #{variableKey} = #{variableValue} WHERE TASK_ID_ = #{taskId}")
    List<Map<String, Object>> updateHistoryVariables(ArrayList variableValue,String taskId,String variableKey);

}

And here's the implementation code,

CustomSqlExecution<CustomActivitiMapper,List<Map<String, Object>>> customSqlExecution = new AbstractCustomSqlExecution<CustomActivitiMapper, List<Map<String, Object>>>() {
                        @Override
                        List<Map<String, Object>> execute(CustomActivitiMapper customActivitiMapper) {
                            return customActivitiMapper.updateHistoryVariables(taskComments,standaloneTask.getId(),variableKey);
                        }
                    }

                    List<Map<String, Object>> resultMap = managementService.executeCustomSql(customSqlExecution);

variableKey is the task variable's name.
taskComments is an arrayList of objects which I'm trying to update.

However I get the following exception

"java.lang.ArrayIndexOutOfBoundsException: 0" .

What could be the issue here?

anitapatil_bld
Confirmed Champ
Confirmed Champ

Hi nagarajut8 _ 

Even I have the same case to achieve, In my case I want to update the task form details of completed task. It will be help full if you share the info how you solved this issue.

Thanks & Regards

Anita Patil