Skip to main content
September 18, 2021
Question

How to populate other fields in Appian?

  • September 18, 2021
  • 6 replies
  • 0 views

Hi Everyone,

Can anyone please tell me how can I populate other fields in interface based on value selected in one of the dropdown field?

Thank You

    6 replies

    venkatasaisatyanarayanaraot000
    September 18, 2021

    HI ,

    Displaying other components in the interface based on the dropdown values depends on the scenario and you can use "showWhen" to control the display of components.

    For you reference i have attached a sample code , where based on the selected values you can see the text fields

    a!localVariables(
    local!showWhen,
    {
    a!dropdownField(
    label: "Drop Down",
    placeholder: "Select a value",
    choiceLabels: {"Yes","No"},
    choiceValues: {"Yes","No"},
    value: local!showWhen,
    saveInto: {
    local!showWhen
    }
    ),
    a!textField(
    label: "Filed when value is Yes",
    showWhen: local!showWhen = "Yes"
    ),
    a!textField(
    label: "Filed when value is No",
    showWhen: local!showWhen = "No"
    )
    }
    )

    Hope this can be helpful

    September 18, 2021

    Thanks Satyanarayan,

    But I am retreiving the fields from the database using expression rule, and want to populate these fields based on one of the value selected in dropdown filed from the database. Please reply.

    venkatasaisatyanarayanaraot000
    September 19, 2021

    HI 

    Call in the Query rule in a local variable and pass the local variable in the choiceLables and ChoiceValues of the dropDown and use showWhen condition in the fields that you want to populate (like i have used in the example showWhen : local!showWhen = "Yes" )

    Participating Frequently
    September 19, 2021

    Hi,

    In case, you want to have just one field to auto-populate the result, you could attempt the below approach:

    a!localVariables(
    local!dbResult:{
    a!map(id:1,name:"Yes Value"),
    a!map(id:2,name:"No Value"),
    },
    local!showWhen,
    {
    a!dropdownField(
    label: "Drop Down",
    placeholder: "Select a value",
    choiceLabels: { "Yes", "No" },
    choiceValues: { "Yes", "No" },
    value: local!showWhen,
    saveInto: { local!showWhen }
    ),
    a!textField(
    label: if(
    local!showWhen = "Yes",
    "Filed when value is Yes",
    "Filed when value is No"
    ),
    value:if(
    local!showWhen = "Yes",
    local!dbResult[1].name,
    local!dbResult[2].name
    ),
    showWhen: or(
    local!showWhen = "Yes",
    local!showWhen = "No"
    ),

    )
    }
    )