Show/hide deployment variable prompt based on value of another variable


I’m creating a Runbook for our project. I’ve 2 project variables that are prompted for during the deployment/run. The first one is a checkbox and the second one is a text field. What I would like to do is to show the text field only if the checkbox is checked.

Is this possible to be done in Octopus?


Hi @OctoCat,

Firstly, let me welcome you to the community :wave:

As far as I can see, this doesn’t appear to be possible due to how the variables are evaluated as part of the run condition for your Runbook i.e. scoped variables and environments.

When you run your runbook, Octopus will prompt for all variables that have been marked as “Prompted Variables” that fit into the scope of the deployment, so you will see all prompted variables.

I did have a look myself to see if this was possible and I am yet to find a way to do this, I will also ask around internally in case I have missed something.

Currently I feel that the best way to try and handle this would be adding the logic into your process of your Runbook (caveat here is that I am not 100% what logic you need here) so I would be keen to also understand this in more detail (if you are happy to share) to understand fully what your are hoping to achieve and the end goal, in case there may be another way to approach this.

As a small example I have a very basic check within my Runbook using a script step that fails the run if the conditions are not met (the checkbox is un-checked):

$condition = $OctopusParameters["Runbook.CheckBox.Prompt"]

if ( $condition -eq $true ){
    Write-Output "Passed Runbook Checks."
else {
	Write-Output "Conditions not met, fail Runbook."
    Exit 1

Write-Output "Value for Text Field: " $OctopusParameters["Runbook.TextFeild.Prompt"]

My variables are as follows:

I hope this helps.

I look forward to hearing from you.

All the best,

1 Like

Thanks for taking the time to reply to me @doug.pipe.

What I have at the moment is what you have suggested. I’m using conditions inside the process script to execute different pieces of code based on the values of the variables. And this does work as expected.

However, my goal to simplify the user interface of the runbook so I can have less documentation explaining stuff.

I have three prompted variables as follows:

  1. Checkbox
  2. TextField A
  3. TextField B

And in my case, TextField A is applicable only if the checkbox is unchecked and TextField B is applicable only when the checkbox is checked.

And currently I have all 3 input fields displayed during the runbook is run. And even if the user enters value in both TextField A and TextField B at the same time, I ignore one of their values in the code in the process script based on the value. So it does work. But what I wanted to do was to show only the required text fields on the UI. That is, if the checkbox is unchecked, don’t prompt for TextField B which will be ignored in the code anyway.


Hi @OctoCat,

Thank you for the update and overview.

I have checked with others internally and can confirm that prompted variables can’t be dynamically shown based on another prompted variable, so unfortunately you won’t be able to do this within the UI.

While not the ideal solution you where hoping for, but as a quick win, you could add in a small description for your variables to help users who run the Runbook.

For example:

Here are my variables:

Within the variable editor window for my prompted variables I can add in a description:

When it comes to entering my prompted variables, I can see any notes (description) that can assist with my prompted variables:

Currently it feels like the logic may be best handled within the Runbook (like you are currently doing).

I probably should have also asked you previously too, (if you are happy to share) what is the Runbook doing? And what/why are the prompted variables doing/needed? I just want to cover all areas in case I am missing something here and there may be another idea to explore.

Hope to hear from you.

All the best,

1 Like

Thanks @doug.pipe. What you have suggested is what I have at the moment. I have entered descriptions which will be shown when users are prompted for the variable inputs. But wanted to simplify the UI if possible, that’s all.

What the runbook is for is to list the files in a server location. One text field is to search for keywords and it will return list of matching directory names in the server. And the other text field is to enter the path to a directory and all its contents will be listed. The checkbox is simply a stetting that’s applicable only for the second text field.

Thanks again for the update @OctoCat.

It feels like you have covered all the bases that I can currently think of here.

Apologies as it may have not been the answer you are hoping for, but if anything changes from Octopus side I will let you know.

Great to talk to you and all the best,

1 Like

No problem. Thanks for the help and it did help me when you confirmed that what I wanted to do was not possible. Because I asked this question to ChatGPT when I started working on this and it very confidently told me that this is possible and even gave me step by step instructions which couldn’t be followed. This sent me on a wild goose chase which has ended with your confirmation above. Also you told me what I could do alternatively, which helped me confirm that what I have currently in place is the right thing to do. So thank you :slight_smile: