Can I generator Id (task or processInstance) by special rule?

Hi.
when I start a processInstance, can I specially some rule for generating id such like each processInstance will start with ”P_", each serviceTask is “ST_” and so on.

Thx

1 Like

Hi Denny.

Simple answer is yes.
Have a look on org.flowable.common.engine.impl.AbstractEngineConfiguration#usePrefixId.

It is not clear for me why do you need serviceTaskId (except model id). Could you provide some use case?

Regards
Martin

halo Martin,
In my case, some business service need to use workflow, the processId, taskId will be the only way to connect workflow service. Someone will not carry what ID it is and someone has some special rule. I would like to get some convenient way for showing like OA task are look like OA_TASK_someUUID etc :smile: (actually it does not needful requirement).


By the way, are these any hook for getting execution type( like porcess, task, gateway) so that I can set some special ID.

Not only add prefix, but also specially generator rule, not like UUID which is ruleless.

As for I know, It IdGenerator.getNextId() Interface can not do it directly.

Thx :smile:

Denny,

Gateway is not persisted, it does not have id in the runtime.

Each EngineConfiguration (ProcessEngineConfiguration too) can have its own idGenerator (org.flowable.common.engine.impl.AbstractEngineConfiguration#idGenerator).
So just set your own idGenerator impl. for the process engine.

It helps for executions/processes, cases, etc., but it does not work for e.g. tasks because they do not have their own engine configuration.
Have a look on org.flowable.common.engine.impl.db.DbSqlSession#insert
I see two possibilities there:

  1. implement your own DbSqlSession - you can handle anything there
  2. implement custom TaskDataManager (based on org.flowable.task.service.impl.persistence.entity.data.impl.MybatisTaskDataManager) to handle task Ids.

Regards
Martin

1 Like

Thx a lot. I will try it :blush::blush: