How to clear field value after the field is disabled

I have two fields like this, only when "Yes" is selected for "Limited" field can user input value for "Limit" field. But I found when "Limit" is disabled, the value is still there.

How can I clear value after "Limit" is disabled?

  Discussion posts and replies are publicly visible

  • 0
    Certified Senior Developer

    a!localVariables(
      local!field1,
      local!field2,
      {
        a!cardLayout(
          contents: {
            a!radioButtonField(
              choiceLabels: { "Yes", "No" },
              choiceValues: { 1, 2 },
              label: "Radio Buttons",
              labelPosition: "ABOVE",
              value: local!field1,
              saveInto: {
                local!field1,
                if(
                  and(
                    local!field1 = 2,
                    a!isNotNullOrEmpty(local!field1)
                  ),
                  a!save(local!field2, null),
                  ""
                )
              },
              choiceLayout: "STACKED",
              validations: {}
            ),
            a!integerField(
              label: "Integer",
              labelPosition: "ABOVE",
              value: local!field2,
              saveInto: { local!field2 },
              refreshAfter: "UNFOCUS",
              validations: {},
              disabled:if(a!isNotNullOrEmpty(local!field1),
              local!field1=2,null)
            )
          },
          height: "AUTO",
          style: "TRANSPARENT",
          marginBelow: "STANDARD"
        )
      }
    )

    Write save on field 1 that makes field2 value null. Have a look into the sample code .

  • 0
    Certified Senior Developer

    Hi  

    Please have a look into this sample code. I hope this will helpful.

    a!localVariables(
      local!limited,
      local!limit,
      {
        a!cardLayout(
          contents: {
            a!radioButtonField(
              choiceLabels: { "Yes", "No" },
              choiceValues: { 1, 2 },
              label: "Limited ?",
              labelPosition: "ABOVE",
              value: local!limited,
              saveInto: {
                local!limited,
                a!save(local!limit,null)
               
              },
              choiceLayout: "STACKED",
              validations: {}
            ),
            a!integerField(
              label: "Limit",
              labelPosition: "ABOVE",
              value: local!limit,
              saveInto: { local!limit },
              refreshAfter: "UNFOCUS",
              validations: {},
              disabled: or(a!isNullOrEmpty(local!limited),local!limited=2)
              
              
            )
          },
          height: "AUTO",
          style: "TRANSPARENT",
          marginBelow: "STANDARD"
        )
      }
    )

  • 0
    Certified Lead Developer

    The important concept in Appian SAIL is, that we do not modify a UI component, but only the underlying data we feed into that component. So to remove a value displayed in one field, just delete that value in a saveInto in another field using a!safe().