Skip to main content
keerthanar849441
January 7, 2024
Question

Multiple Validation group on a same field

  • January 7, 2024
  • 8 replies
  • 2 views

Can I have multiple validation groups for the one sail component? 

Considering I have Field A, Field B, and 3 buttons. Field A is mandatory for 2 buttons Button_A and Button_B. How to achieve this?

{
    a!columnsLayout(
      columns: {
        a!columnLayout(
          contents: {
            a!textField(
              label: "Name",
              labelPosition: "ABOVE",
              saveInto: {},
              required: true,
              refreshAfter: "UNFOCUS",
              validationGroup:  
                {
                  "Button_A",
                  "Button_B"
                }
              
            ),
            a!textField(
              label: "Mobile Number",
              labelPosition: "ABOVE",
              saveInto: {},
              required: true(),
              refreshAfter: "UNFOCUS",
              validations: {},
              validationGroup: "Button B"
            )
          }
        ),
        
      }
    ),
    a!buttonArrayLayout(
      buttons: {
        a!buttonWidget(
          label: "Button A",
          style: "NORMAL",
          submit: true(),
          validationGroup: "Button_A"
        ),
        a!buttonWidget(
          label: "Button B",
          style: "NORMAL",
          submit: true(),
          validationGroup: "Button_B"
        ),
        a!buttonWidget(
          label: "Button C",
          style: "NORMAL",
          submit: true(),
          validationGroup: "Button_C"
        )
      },
      align: "START"
    )
}

8 replies

mudits1812
January 7, 2024

Hi [mention:ea050100b6b344e79c623ecd06231030:e9ed411860ed4f2ba0265705b8793d05] , 
I hope ,I have understood your requirement correctly. 
I updated the code, which you can try. 
Here, Button_A and Button_B will check requiredness for "Name" textField. 
Whereas, Button_C will check requiredness for "Mobile_Number" textfField. 

a!localVariables(
  local!name,
  local!number,
  {
    a!columnsLayout(
      columns: {
        a!columnLayout(
          contents: {
            a!textField(
              label: "Name",
              labelPosition: "ABOVE",
              saveInto: local!name,
              value: local!name,
              required: true,
              refreshAfter: "UNFOCUS",
              validationGroup: "Name_Condition",

            ),
            a!textField(
              label: "Mobile Number",
              labelPosition: "ABOVE",
              value: local!number,
              saveInto: local!number,
              required: true(),
              refreshAfter: "UNFOCUS",
              validations: {},
              validationGroup: "MobNumber_Condition"
            )
          }
        ),

      }
    ),
    a!buttonArrayLayout(
      buttons: {
        a!buttonWidget(
          label: "Button A",
          style: "",
          submit: true(),
          validationGroup: "Name_Condition"
        ),
        a!buttonWidget(
          label: "Button B",
          style: "",
          submit: true(),
          validationGroup: "Name_Condition"
        ),
        a!buttonWidget(
          label: "Button C",
          style: "",
          submit: true(),
          validationGroup: "MobNumber_Condition"
        )
      },
      align: "START"
    )
  }
)


In addition to this, you can refer, 
https://docs.appian.com/suite/help/23.4/recipe-use-validation-group-for-buttons-with-multiple-validation-rules.html

harshitb6843
January 9, 2024

This will be the ideal way of achieving this. Instead of having one validation group per button, you should have one validation group per field and then use it in the required buttons. 

stefanhelzle0001
January 7, 2024

The parameter name "validationGroup" is in singular and only accepts a single group.

Can you help me to understand what you want to achieve? There are a few options we could discuss.

fernandob9308
November 18, 2024

Hello,

I have a different case. 

I have a form with two buttons with validate: true(), and each with a different validationGroup.

One is a save button which only requires one field.

The other one is a submit button which requires all of the fields to be filled.

Therefore, there is a field (multipleDropdownField) that is required for both buttons.

The problem is that the "validationGroup" parameter of the multipleDropdown field only allows a Text and not an array of Text, and the value of the button (ri!buttonValue) cannot be used in an "if" statement because when the buttons are clicked, ri!buttonValue does not change unless the validations are satisfied. 

I hope I am explaining and I hope you can help me with my problem.

Thanks in advance.

stefanhelzle0001
November 18, 2024

I think you cannot use validation groups to solve this challenge.

Did you consider to just keep both buttons disabled until that common field has a value, and then let the normal validation take over?