Need to put shown condition in Button

Hi All,

I'm having a button "COMPLETE"

i want to put a shown condition on it in the following basis


I'm having an array {"Completed","Not Completed"},

If both the values in that array are in completed status then only i want to show that button.

Could you please help me with the logic.

Thanks

  Discussion posts and replies are publicly visible

Parents
  • This is done utilizing the "showWhen" parameter.  This example assumes your array always contains 2 values, as noted in the original post, and includes dropdowns for you to change the array values to see it in action.

    Note that often instead of using the "showWhen" parameter to hide the button, I often use the "disabled" parameter so users know it exists, but does not let them press it until the desired values are present.  Comment out the showWhen code to see how that functionality works.

    a!localVariables(
      local!data: {"Completed","Not Completed"},
      
      {
        a!columnsLayout(
          columns: {
            a!columnLayout(
              contents: {
                a!dropdownField(
                  label: "Data 2",
                  labelPosition: "ADJACENT",
                  choiceLabels: {"Completed","Not Completed"},
                  choiceValues: {"Completed","Not Completed"},
                  value: local!data[1],
                  saveInto: local!data[1]
                )
              }
            ),
            a!columnLayout(
              contents: {
                a!dropdownField(
                  label: "Data 2",
                  labelPosition: "ADJACENT",
                  choiceLabels: {"Completed","Not Completed"},
                  choiceValues: {"Completed","Not Completed"},
                  value: local!data[2],
                  saveInto: local!data[2]
                )
              }
            )
          }
        ),
        a!buttonArrayLayout(
          align: "CENTER",
          buttons: a!buttonWidget(
            label: "COMPLETE",
            showWhen: and(
              index(local!data,1,null)="Completed",
              index(local!data,2,null)="Completed"
            ),
            disabled: or(
              index(local!data,1,null)<>"Completed",
              index(local!data,2,null)<>"Completed"
            )
          )
        )
      }
    )

Reply
  • This is done utilizing the "showWhen" parameter.  This example assumes your array always contains 2 values, as noted in the original post, and includes dropdowns for you to change the array values to see it in action.

    Note that often instead of using the "showWhen" parameter to hide the button, I often use the "disabled" parameter so users know it exists, but does not let them press it until the desired values are present.  Comment out the showWhen code to see how that functionality works.

    a!localVariables(
      local!data: {"Completed","Not Completed"},
      
      {
        a!columnsLayout(
          columns: {
            a!columnLayout(
              contents: {
                a!dropdownField(
                  label: "Data 2",
                  labelPosition: "ADJACENT",
                  choiceLabels: {"Completed","Not Completed"},
                  choiceValues: {"Completed","Not Completed"},
                  value: local!data[1],
                  saveInto: local!data[1]
                )
              }
            ),
            a!columnLayout(
              contents: {
                a!dropdownField(
                  label: "Data 2",
                  labelPosition: "ADJACENT",
                  choiceLabels: {"Completed","Not Completed"},
                  choiceValues: {"Completed","Not Completed"},
                  value: local!data[2],
                  saveInto: local!data[2]
                )
              }
            )
          }
        ),
        a!buttonArrayLayout(
          align: "CENTER",
          buttons: a!buttonWidget(
            label: "COMPLETE",
            showWhen: and(
              index(local!data,1,null)="Completed",
              index(local!data,2,null)="Completed"
            ),
            disabled: or(
              index(local!data,1,null)<>"Completed",
              index(local!data,2,null)<>"Completed"
            )
          )
        )
      }
    )

Children