cancel
Showing results for 
Search instead for 
Did you mean: 

Is it possible to create a local task variable on a completion event?

robojeff
Champ in-the-making
Champ in-the-making
I'd like to create a local task variable from a TaskListener when Activiti invokes it for a "complete" event:


public class RoutingOptionAuditor implements TaskListener {
    private Expression routeExpression;

    @Override
    public void notify(DelegateTask delegateTask) {
        String routingOption = getRoutingOption(delegateTask); // this code grabs some text from an enumerated form property value

        TaskService taskService = getTaskService(delegateTask);
        taskService.setVariableLocal(delegateTask.getId(), "routingOption", routingOption);
}


This code causes a SQL Exception:


### Error updating database.  Cause: org.h2.jdbc.JdbcSQLException: Referential integrity constraint violation: "ACT_FK_VAR_EXE: PUBLIC.ACT_RU_VARIABLE FOREIGN KEY(EXECUTION_ID_) REFERENCES PUBLIC.ACT_RU_EXECUTION(ID_) ('5')"; SQL statement:
delete from ACT_RU_EXECUTION where ID_ = ? and REV_ = ? [23503-192]
### The error may involve org.activiti.engine.impl.persistence.entity.ExecutionEntity.deleteExecution-Inline
### The error occurred while setting parameters
### SQL: delete from ACT_RU_EXECUTION where ID_ = ? and REV_ = ?
### Cause: org.h2.jdbc.JdbcSQLException: Referential integrity constraint violation: "ACT_FK_VAR_EXE: PUBLIC.ACT_RU_VARIABLE FOREIGN KEY(EXECUTION_ID_) REFERENCES PUBLIC.ACT_RU_EXECUTION(ID_) ('5')"; SQL statement:
delete from ACT_RU_EXECUTION where ID_ = ? and REV_ = ? [23503-192]


Does the "complete" TaskListener event occur too late in the task's lifecycle to be adding local task variables to it?  If so, is there a recommended technique for trying to do this?
1 ACCEPTED ANSWER

gdharley
Elite Collaborator
Elite Collaborator

I believe the following thread will answer your question:

 

Thanks,
greg

View answer in original post

1 REPLY 1

gdharley
Elite Collaborator
Elite Collaborator

I believe the following thread will answer your question:

 

Thanks,
greg