Radio Button Component is loosing its selection

Hi All,

We encountered a challenge with the Radio Button Component. Under certain condition it is loosing or 'forgetting' the selected radio button.

We are using it to display the status in a workflow. Based on the users role and the status the entity is in, only certain options can be selected, so we are adjusting the choices.

Below is a code example what we are doing. As you might see, if you select option 3, it stays only a split second on the UI and then the selection disappears. And yes - we already
have submitted a support ticket to Appian, but it looks like the component will not be changed. 

Any suggestions how to overcome this? We have our own ideas, but would like to see first what the community will contribute.
(We will publish our version tomorrow).

Thanks

a!localVariables(
  local!selection:1,
  local!choices:a!refreshVariable(
    refreshAlways: true,
    value: if(
      local!selection = 3,
      {1,3},
      {1,2,3}
    )
  ),
  {
  a!radioButtonField(
    choiceValues: local!choices,
    choiceLabels: local!choices,
    value: local!selection,
    saveInto: {
      local!selection
    },
    
  ),
  a!textField(
    label: local!choices,
    value: local!selection
  ),
  }
 )
  

  Discussion posts and replies are publicly visible

  • Interesting. It seems the value of local!selection is intact, however since the local!choices gets refreshed it is not able to retain/display its selected value.

    Following work-around would do the job.

    a!localVariables(
      local!selection:1,
      local!choice1: {1,3},
      local!choice2: {1,2,3},
      {
        if(
          local!selection = 3,
          a!radioButtonField(
            choiceValues: local!choice1,
            choiceLabels: local!choice1,
            value: local!selection,
            saveInto: local!selection
          ),
          a!radioButtonField(
            choiceValues: local!choice2,
            choiceLabels: local!choice2,
            value: local!selection,
            saveInto: local!selection
          )
        ),
        a!textField(
          label: if(local!selection = 3, local!choice1, local!choice2),
          value: local!selection
        ),
      }
    )

  • 0
    Certified Lead Developer

    I am interested in the purpose of this :-)

  • +1
    Certified Lead Developer

    Interesting since it doesn't seem to affect the alternative case where you collapse the choices to make '3' go away when '2' is selected.

    My best guess is that the radio button's "filled" status in the UI is not refreshed after the choices collapse (perhaps Appian doesn't think it would need to refresh it again since the radio button itself is what caused the value update). 

    I also notice that if you edit the text box to save into local!selection, and type the value of 3 when the current selection is 1, it actually works as expected - in that case i'm guessing it's because appian evaluates the new selection value, reevaluates the new choices, then reevaluates the radio button field's status (correctly).

    a!localVariables(
      local!selection: 1,
      local!choices: a!refreshVariable(
        refreshAlways: true,
        value: if(
          local!selection = 3,
          {1,3},
          {1,2,3}
        )
      ),
      
      {
        a!radioButtonField(
          choiceValues: local!choices,
          choiceLabels: local!choices,
          value: local!selection,
          saveInto: {
            local!selection
          },
        ),
        a!textField(
          label: local!choices,
          value: local!selection,
          /* edited to add save-back ability here: */
          saveInto: a!save(local!selection, tointeger(save!value))
        )
      }
    )

  • Hi All,

    Thanks for you contributions. As you might imagine, the example was a simplified one. Our real world case has much more choices then 3 - about 5 to six, depicting the workflow status the case is in and a lot of roles which can change the status of the case back and forth, depending in what state the case is and what role the user has. We reflecting that by just showing the user the radio buttons he can choose from. 

    So any solution as a work around should avoid that we have to think of all the permutation that could happening. 

    As Mike pointed out correctly, the issue with the Radio Button Component is, that is doesn't refreshes again when a selection is made. So we can do that ourselves. Please see the code below, which is independent from the number of choices we might have to present or reduce.

    {
      a!localVariables(
        local!selection: 1,
        local!selection2: tointeger(null),
        local!choices: a!refreshVariable(
          refreshAlways: true,
          value: if(or(local!selection = 3,local!selection2 = 3), { 1, 3 }, { 1, 2, 3 })
        ),
        {
          a!radioButtonField(
            label: "radio1",
            choiceLayout: "COMPACT",
            choiceValues: local!choices,
            choiceLabels: local!choices,
            saveInto: {
              local!selection2,
              a!save(local!selection, tointeger(null))
            },
            value: local!selection,
            showWhen: isnull(local!selection2)
          ),
          a!radioButtonField(
            label: "radio2",
            choiceLayout: "COMPACT",
            choiceValues: local!choices,
            choiceLabels: local!choices,
            saveInto: {
              local!selection,
              a!save(local!selection2, tointeger(null))
            },
            value: local!selection2,
            showWhen: isnull(local!selection)
          )
        }
      )
    }

  • Hi Stefan, 
    The purpose of this from the business perspective is described below. From the meta level, maybe we can raise awareness from Appian considering to fix the component? 

    Or at least provide some solution for the ones in the community facing similar challenges. 

    Thanks,

    Juergen