validations

Certified Associate Developer

Hi, 

I have a dropdown with 3 values. I store the selected dropdown value in a local variable( local!selection will be either 1/2/3 based on the selection by the user).User can create multiple records. By clicking on a dropdown value, a form opens up and the user can submit the form. 

First time, if the user select the first option (A) in the dropdown, the next time the user should select the same option (A). I need a validation here, which should throw an error if the user selects the other two option. 

My record is a list of array. Can someone help here. 

  Discussion posts and replies are publicly visible

Parents
  • +1
    Certified Associate Developer

    Hi Hema, 

    you just need to put a validation in the dropdown of the record form. Take a look to this example:

    a!localVariables(
      local!selectionRecord,
      local!selection: 1,
    {
      a!dropdownField(
        label: "Dropdown",
        labelPosition: "ABOVE",
        placeholder: "--- Select a Value ---",
        choiceLabels: {"Option 1", "Option 2", "Option 3", "Option 4",
                        "Option 5", "Option 6", "Option 7", "Option 8",
                        "Option 9", "Option 10", "Option 11", "Option 12"},
        choiceValues: {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12},
        value:local!selectionRecord,
        saveInto: {local!selectionRecord},
        searchDisplay: "AUTO",
        validations: {
         if(
           local!selectionRecord <> local!selection,
           "Must be the same as the first selection",
           ""
         )
          
        }
      )
    }
    )

Reply
  • +1
    Certified Associate Developer

    Hi Hema, 

    you just need to put a validation in the dropdown of the record form. Take a look to this example:

    a!localVariables(
      local!selectionRecord,
      local!selection: 1,
    {
      a!dropdownField(
        label: "Dropdown",
        labelPosition: "ABOVE",
        placeholder: "--- Select a Value ---",
        choiceLabels: {"Option 1", "Option 2", "Option 3", "Option 4",
                        "Option 5", "Option 6", "Option 7", "Option 8",
                        "Option 9", "Option 10", "Option 11", "Option 12"},
        choiceValues: {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12},
        value:local!selectionRecord,
        saveInto: {local!selectionRecord},
        searchDisplay: "AUTO",
        validations: {
         if(
           local!selectionRecord <> local!selection,
           "Must be the same as the first selection",
           ""
         )
          
        }
      )
    }
    )

Children