# Workflow versioning to exclude an activity from workflows triggered in future

**URL:** <https://community.temporal.io/t/workflow-versioning-to-exclude-an-activity-from-workflows-triggered-in-future/12540>\
**Category:** Community Support\
**Tags:** java-sdk\
**Created:** [June 18, 2024, 1:20pm UTC](https://community.temporal.io/t/workflow-versioning-to-exclude-an-activity-from-workflows-triggered-in-future/12540 "2024-06-18T13:20:10Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Joe\_Antony](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/joe_antony/32/4434_2.png) [@Joe\_Antony](https://community.temporal.io/u/Joe_Antony)\
**Post date:** [June 18, 2024, 1:20pm UTC](https://community.temporal.io/t/workflow-versioning-to-exclude-an-activity-from-workflows-triggered-in-future/12540/1 "2024-06-18T13:20:10Z")

</div>

Hi all,

I have the following code snippet:

```auto
activity1.function1();
Workflow.await(() -> ...); // The workflow waits until a signal is received
activity2.function2();

```

I triggers a workflow, let’s call it `workflow1`.  
`workflow1` is waiting for the signal.

Now, I want to exclude `activity2` for all the workflows triggered in future.

I do the following:

```auto
activity1.function1();
Workflow.await(() -> ...);
int version = Workflow.getVersion("excludeActivity2", Workflow.DEFAULT_VERSION, 1);
if (version == 1) {
    log.info("Activity 2 excluded.");
} else {
    activity2.function2();
}

```

After re-running my application, I triggers another workflow, let’s call it `workflow2`.  
`workflow2` is also waiting for the signal.

Then I send signals to both `workflow1` and `workflow2`.

But both `workflow1` and `workflow2` executes the if part, i.e., “Activity 2 excluded.” is printed.

Am I missing something while versioning?  
How can I make sure only `workflow1` executes `activity2.function2();`?  
Temporal version used is 1.23.2

Thanks,  
Joe

---

<div class="post-metadata">

**Author:** ![maxim](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/maxim/32/8_2.png) [@maxim](https://community.temporal.io/u/maxim)\
**Post date:** [June 19, 2024, 5:54pm UTC](https://community.temporal.io/t/workflow-versioning-to-exclude-an-activity-from-workflows-triggered-in-future/12540/2 "2024-06-19T17:54:36Z")

</div>

`Workflow.getVersion` is evaluated at the time of the call. This allows fixing bugs in the already running workflows. I’m not sure why you want the workflow that started before still execute the old logic.

If you indeed want to fix the workflow version at the beginning of the workflow execution, call `getVersion` at the top of the workflow function.

---

<div class="post-metadata">

**Author:** ![Joe\_Antony](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/joe_antony/32/4434_2.png) [@Joe\_Antony](https://community.temporal.io/u/Joe_Antony)\
**Post date:** [June 19, 2024, 6:34pm UTC](https://community.temporal.io/t/workflow-versioning-to-exclude-an-activity-from-workflows-triggered-in-future/12540/3 "2024-06-19T18:34:29Z")

</div>

Thanks a lot for the solution, @maxim. Calling `getVersion()` at the top of the workflow did the trick.
