Call only specific values of variable

Hi all,

I have a runbook in which the user will give a value on each of two different prompt variables.
The first prompt variable should allow the user to select one of a pre-defined set of values, which are already in the variable set.
Is there any way for this to be implemented?
Thank you.

Hi Andreas,

Thanks for reaching out on our community forums!

You can implement a drop-down for prompted variables by adding a new variable in the project and selecting the open editor option.

Once the editor is open, select the ‘Prompt for value’ checkbox, and then you can select the ‘control type’ and choose the drop-down option.

Hopefully, this helps you get going.

Thanks,
Brent

Hello @brent_kinney ,

Thank you for your reply.
I will try to implement this solution. My question is whether the values that will be added in the dropdown list can be populated dynamically via an API call, or it needs to be statically defined when the variable is first set?
Thank you again.

Hi Andreas,
You can create a dropdown list variable using an API call. We have a PowerShell script on our GitHub that can add or edit variable sets. To create a variable with a dropdown list, that script would need some modification, but to help you get started, I have included the JSON block of a variable with some dropdown info to see what the format looks like.

Here is my variable info:

Here is the JSON display for this variable:

{
      "Id": "286c5d18-9a80-6730-ab12-b3b7840c7aa4",
      "Name": "ValueList",
      "Value": null,
      "Description": null,
      "Scope": {},
      "IsEditable": true,
      "Prompt": {
        "Label": "",
        "Description": "",
        "Required": false,
        "DisplaySettings": {
          "Octopus.ControlType": "Select",
          "Octopus.SelectOptions": "80|Set to Port 80\n8080|Set to Port 8080\n8081|Set to Port 8081"
        }
      },
      "Type": "String",
      "IsSensitive": false
    }

Before running any script, please read and test thoroughly as they are not guaranteed to work in all environments.

I hope this helps point you in the right direction.

Thanks,
Brent

1 Like

Thank you very much. Will give it a try.

1 Like

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