# Is there any way to add flow element to the process definition on a distributed application

**URL:** <https://forum.flowable.org/t/is-there-any-way-to-add-flow-element-to-the-process-definition-on-a-distributed-application/7058>\
**Category:** Flowable Engine\
**Created:** [November 11, 2020, 2:04am UTC](https://forum.flowable.org/t/is-there-any-way-to-add-flow-element-to-the-process-definition-on-a-distributed-application/7058 "2020-11-11T02:04:32Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![aheroaa](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/aheroaa/32/2087_2.png) [@aheroaa](https://forum.flowable.org/u/aheroaa)\
**Post date:** [November 11, 2020, 2:04am UTC](https://forum.flowable.org/t/is-there-any-way-to-add-flow-element-to-the-process-definition-on-a-distributed-application/7058/1 "2020-11-11T02:04:33Z")

</div>

Hi everyone.

What I want to do is that when I come to a task, I’d like to add a task before or after my task.

**When the application is a stand-alone one** , I may change the process definiton dynamicly by adding UserTasks and SequenceFlows, using `runtimeService.createChangeActivityStateBuilder` API. It works well.

**But when I came to a distributed application** , the problem became more difficult. In this issue, I can not get the change on another server.

I’ve made some attempts as follow.

When the issue comes, I copy and deploy a new process definition and change flow nodes, sequence flows on the new definition, witch will be durable in the db. So even on another server I will gain the changes.

But when I use the `runtimeService.createChangeActivityStateBuilder` API to migarate task from one to another. The engine tells me **Cannot find activity \* in process definition**. I think it is because execution still use the old process definition.

May I change process definition the execution uses at runtime? Or Is there any solution may help me.

Thanks a lot.

---

<div class="post-metadata">

**Author:** ![joram](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/joram/32/26_2.png) [@joram](https://forum.flowable.org/u/joram)\
**Post date:** [November 16, 2020, 8:22pm UTC](https://forum.flowable.org/t/is-there-any-way-to-add-flow-element-to-the-process-definition-on-a-distributed-application/7058/2 "2020-11-16T20:22:50Z")

</div>

> [@aheroaa](#):
>
> May I change process definition the execution uses at runtime?

Yes, you can execute the SetProcessDefinitionVersionCmd programmatically via the managementService#executeCommand.

> [@aheroaa](#):
>
> But when I use the `runtimeService.createChangeActivityStateBuilder` API to migarate task from one to another. The engine tells me **Cannot find activity \* in process definition**. I think it is because execution still use the old process definition.

I’m not yet following fully - where and when do you call this API? Can you share a bit of the code you’re using to do this?
