# How to retrieve the current cluster id in an application form?

**URL:** https://discourse.openondemand.org/t/how-to-retrieve-the-current-cluster-id-in-an-application-form/4290
**Category:** Get Help
**Created:** [June 5, 2025, 5:33pm UTC](https://discourse.openondemand.org/t/how-to-retrieve-the-current-cluster-id-in-an-application-form/4290 "2025-06-05T17:33:54Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![xpillons](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/xpillons/32/1256_2.png) [@xpillons](https://discourse.openondemand.org/u/xpillons)
#### Post date: [June 5, 2025, 5:33pm UTC](https://discourse.openondemand.org/t/how-to-retrieve-the-current-cluster-id-in-an-application-form/4290/1 "2025-06-05T17:33:54Z")

</div>

I’m looking for help in order to implement the global static list presented in this tutorial  
[Use a Global Static List — Open OnDemand 4.0.0 documentation](https://osc.github.io/ood-documentation/latest/tutorials/tutorials-interactive-apps/add-custom-queue/global-static-list.html)

In this example, the cluster name is hardcoded to `my_cluster` and must correspond to an existing one as highligted in the warning message.

> # ~/ondemand/dev/jupyter/form.yml.erb
> 
> \<%-  
> queues = OodAppkit.clusters[:my\_cluster].custom\_config[:queues]  
> -%\>

Instead of using a hardcoded one, how can I retrieved the current cluster used in the form ? This will allows me to have a generic application form while having different queue definitions per cluster.

---

<div class="post-metadata">

### Author: ![travert](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/travert/32/3074_2.png) [@travert](https://discourse.openondemand.org/u/travert)
#### Post date: [June 5, 2025, 11:47pm UTC](https://discourse.openondemand.org/t/how-to-retrieve-the-current-cluster-id-in-an-application-form/4290/2 "2025-06-05T23:47:25Z")

</div>

I’m not sure this can be done without introducing a dropdown for the user to select which cluster to use. As far as I know the `form.yml.erb` is not cluster-aware — though with OOD, there are often undocumented behaviors, so it’s hard to say definitively.

One possible workaround might involve using an environment variable (e.g., `ENV['OOD_CLUSTER']`) and calling `OodAppkit.clusters[ENV['OOD_CLUSTER'].to_sym]` to retrieve the appropriate cluster config. But this requires coordination from the sysadmin side to ensure that variable is always correctly set, which may not be simpler than just specifying the cluster statically in the form.

In short, there’s no built-in API in OOD to automatically detect or dynamically select the current cluster within the form that I know of. Any dynamic behavior would need to be implemented manually, likely scripting and environment variables, and even then it’s unclear how reliable or maintainable that approach would be.

As always, it could be there’s a way here that is just not documented or known, but I am unsure myself.

---

<div class="post-metadata">

### Author: ![xpillons](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/xpillons/32/1256_2.png) [@xpillons](https://discourse.openondemand.org/u/xpillons)
#### Post date: [June 6, 2025, 7:04am UTC](https://discourse.openondemand.org/t/how-to-retrieve-the-current-cluster-id-in-an-application-form/4290/3 "2025-06-06T07:04:42Z")

</div>

Thanks Travis for your answer. I’m trying to isolate the application form from the cluster definition and want to inject enhanced attribute to the default partition names.  
The fact is that when there are multiple clusters, a dropdown is automatically added by OOD, so maybe the way I’m doing it is not the right one. At the GOOD conference there were some examples presented with initializers and plugins, I may investigate that path too.

If someone else has an example to share on how to dynamically query partitions other than autoqueues, I will be pleased to try.

Thanks,  
Xavier

---

<div class="post-metadata">

### Author: ![jeff.ohrstrom](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/jeff.ohrstrom/32/136_2.png) [@jeff.ohrstrom](https://discourse.openondemand.org/u/jeff.ohrstrom)
#### Post date: [June 6, 2025, 1:16pm UTC](https://discourse.openondemand.org/t/how-to-retrieve-the-current-cluster-id-in-an-application-form/4290/4 "2025-06-06T13:16:29Z")

</div>

That reminds me to update that portion of the tutorial to include the ondemand.d configuration for `global_bc_form_items`.

I think you could use either, but ondemand.d configuration may be cleaner.

> **[User Form (form.yml.erb) — Open OnDemand 4.0.0 documentation](https://osc.github.io/ood-documentation/latest/how-tos/app-development/interactive/form.html#global-batch-connect-form-items)**

In any case, I think the resolution is simple - you create a list of all the queues on all clusters, then attach dynamic `data-` directives to it so they’ll be able to show and hide themselves based on the current choice of cluster.

Technically they’ll be there in the HTML, but the user won’t see them in the dropdown given the rules you apply to them.

`data-option-for-cluster-`

> **[Dynamic Form Widgets — Open OnDemand 4.0.0 documentation](https://osc.github.io/ood-documentation/latest/how-tos/app-development/interactive/dynamic-form-widgets.html#hiding-select-options)**

and new in 4.0 we have `data-exclusive-option-for-`

> **[Dynamic Form Widgets — Open OnDemand 4.0.0 documentation](https://osc.github.io/ood-documentation/latest/how-tos/app-development/interactive/dynamic-form-widgets.html#exclusive-options)**

---

<div class="post-metadata">

### Author: ![xpillons](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/xpillons/32/1256_2.png) [@xpillons](https://discourse.openondemand.org/u/xpillons)
#### Post date: [June 10, 2025, 9:50am UTC](https://discourse.openondemand.org/t/how-to-retrieve-the-current-cluster-id-in-an-application-form/4290/5 "2025-06-10T09:50:23Z")

</div>

Thank you Jeff.  
I was finally able to make it works by doing this :

- define the cluster list and names in global\_bc\_form\_items as a hidden text field in case of a simple cluster or a select if multiple
- define a global partition list with all partitions for all clusters which can be filtered using the data-exclusives attributes

By doing this way I can isolate my application form from the cluster and partition definitions and build a dynamic cluster registration mechanism.

Xavier

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex015/uploads/osc/original/2X/b/bae70bd0ed39a3ae769c2108155f4cb3e9da8385.png) [@system](https://discourse.openondemand.org/u/system)
#### Post date: [December 7, 2025, 9:50am UTC](https://discourse.openondemand.org/t/how-to-retrieve-the-current-cluster-id-in-an-application-form/4290/6 "2025-12-07T09:50:37Z")

</div>

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.
