# Workflow name as environment variable

**URL:** https://community.temporal.io/t/workflow-name-as-environment-variable/7017
**Category:** Community Support
**Tags:** java-sdk
**Created:** [January 22, 2023, 8:06am UTC](https://community.temporal.io/t/workflow-name-as-environment-variable/7017 "2023-01-22T08:06:56Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![Artur](https://avatars.discourse-cdn.com/v4/letter/a/53a042/32.png) [@Artur](https://community.temporal.io/u/Artur)
#### Post date: [January 22, 2023, 8:06am UTC](https://community.temporal.io/t/workflow-name-as-environment-variable/7017/1 "2023-01-22T08:06:56Z")

</div>

Hi,  
Is there an option to set the workflow name based on (environment/dynamic) variables?  
I didn’t find a solution is the docs, is it possible?  
I saw that @WorkflowMethod(name= “”) - must be a constant…

Thanks,  
Artur

---

<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: [January 22, 2023, 5:49pm UTC](https://community.temporal.io/t/workflow-name-as-environment-variable/7017/2 "2023-01-22T17:49:38Z")

</div>

What is the use case for this?

---

<div class="post-metadata">

### Author: ![Artur](https://avatars.discourse-cdn.com/v4/letter/a/53a042/32.png) [@Artur](https://community.temporal.io/u/Artur)
#### Post date: [January 22, 2023, 6:53pm UTC](https://community.temporal.io/t/workflow-name-as-environment-variable/7017/3 "2023-01-22T18:53:40Z")

</div>

It requested by our PO, he wants a different workflow type/name for each environment,  
from your answer, I’m assuming I can tell them this is not possible by SDK?

---

<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: [January 22, 2023, 7:13pm UTC](https://community.temporal.io/t/workflow-name-as-environment-variable/7017/4 "2023-01-22T19:13:21Z")

</div>

I’m not sure what value such feature provides given that each environment is expected to live in its own namespace

You can create your `ReplayWorkflowFactory,` which internally will delegate to `POJOWorkflowImplementationFactory` and perform name mapping. One caveat is that `POJOWorkflowImplementationFactory` is an internal implementation, so there is no guarantee about its API stability.

---

<div class="post-metadata">

### Author: ![Artur](https://avatars.discourse-cdn.com/v4/letter/a/53a042/32.png) [@Artur](https://community.temporal.io/u/Artur)
#### Post date: [January 22, 2023, 7:25pm UTC](https://community.temporal.io/t/workflow-name-as-environment-variable/7017/5 "2023-01-22T19:25:56Z")

</div>

For me, also “This is currently not possible, due to API stability” is perfectly fine - Thanks Maxim!

---

<div class="post-metadata">

### Author: ![Luke](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/luke/32/5106_2.png) [@Luke](https://community.temporal.io/u/Luke)
#### Post date: [April 4, 2024, 12:09pm UTC](https://community.temporal.io/t/workflow-name-as-environment-variable/7017/6 "2024-04-04T12:09:34Z")

</div>

Hi Maxim,

I have a use case that requires passing the workflow name since it’s not constant. We have a proto file with workflow name that we share across domains. This allows us decoupling between the domains. One domain can take the WF name from the proto file and registers the WF under that name, and the other uses the porto to know which WF it can call.

Can you suggest a way to work around it ?

Thanks.

---

<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: [April 4, 2024, 2:55pm UTC](https://community.temporal.io/t/workflow-name-as-environment-variable/7017/7 "2024-04-04T14:55:38Z")

</div>

Use [DynamicWorkflow](https://github.com/temporalio/sdk-java/blob/master/temporal-sdk/src/main/java/io/temporal/workflow/DynamicWorkflow.java).
