[Application Designer]How to display custom variables according to a dynamic value

DrissiReda
DrissiReda Registered Posts: 76 ✭✭✭✭✭

I'm trying an application where I have some custom variables to edit.

One of them is a dropdown menu that can be either "local" or "remote".
According to this value I want different fields in custom variables to be displayed.

For example for "local" we will only have fields "user" "path" and "fileType".
For "remote" there will be a field "url" that overrides global variable "url" that will be added and also variable "api key" instead of "user" that overloads "api_key". The label should also change.

Is this achievable? Anybody did this before?

Best Answer

  • DarinB
    DarinB Dataiker, Dataiku DSS Core Designer, Dataiku DSS ML Practitioner, Dataiku DSS Adv Designer, Registered Posts: 9 Dataiker
    Answer ✓

    Hi @DrissiReda,

    I believe this is achievable using the visibility condition when defining the custom variables. Here's some documentation on creating parameters for Dataiku Applications: Parameters.

    Here's some example JSON to define the custom variables based on your question.


    [
    {
    "name": "separator_type",
    "type": "SEPARATOR",
    "label": "Connection Type"
    },
    {
    "name": "connection_type",
    "type": "SELECT",
    "label": "Local or Remote",
    "mandatory": true,
    "selectChoices": [
    {
    "value": "local",
    "label": "Local"
    },
    {
    "value": "remote",
    "label": "Remote"
    }
    ]
    },
    {
    "name": "separator_local",
    "type": "SEPARATOR",
    "label": "Local connection",
    "visibilityCondition": "model.connection_type == 'local'"
    },
    {
    "name": "user",
    "type": "STRING",
    "label": "User",
    "visibilityCondition": "model.connection_type == 'local'"
    },
    {
    "name": "path",
    "type": "STRING",
    "label": "Path",
    "visibilityCondition": "model.connection_type == 'local'"
    },
    {
    "name": "file_type",
    "type": "STRING",
    "label": "File Type",
    "visibilityCondition": "model.connection_type == 'local'"
    },
    {
    "name": "separator_remote",
    "type": "SEPARATOR",
    "label": "Remote connection",
    "visibilityCondition": "model.connection_type == 'remote'"
    },
    {
    "name": "url",
    "type": "STRING",
    "label": "URL",
    "visibilityCondition": "model.connection_type == 'remote'"
    },
    {
    "name": "api_key",
    "type": "PASSWORD",
    "label": "API Key",
    "visibilityCondition": "model.connection_type == 'remote'"
    }
    ]

    Here's a screenshot when "Local" is selected.

    Screenshot 2025-04-19 at 1.05.33 AM.png

    Here's a screenshot when "Remote" is selected.

    Screenshot 2025-04-19 at 1.06.02 AM.png

Answers

Setup Info
    Tags
      Help me…