Skip to main content
July 29, 2022
Question

validations to check date field within last 12 months

  • July 29, 2022
  • 3 replies
  • 1 view

when a user inputs the date in date field other than within last 12 months then validation error should popup.. Thanks for your time and help..

3 replies

stefanhelzle0001
Brainy
July 29, 2022

Validations in general:

https://docs.appian.com/suite/help/22.2/recipe-add-multiple-validation-rules-to-one-component.html

Check for number of days:

tointeger(today() - date(2021,1,1)) > 365

scarg
July 29, 2022

Hi Prasad,

Try this:

a!localVariables(
  local!date,
  a!formLayout(
    label: "Example: Date Field Validation Rule",
    contents:{
      a!dateField(
        label: "Select a valid date",
        instructions: "Enter a date within last 12 months",
        value: local!date,
        saveInto: local!date,
        validations: {
          if(
            not(
              and(
                today() - 365 <= todate(local!date),
                local!date <= today()
              )
            ),
            "Date selected is not within last 12 months",
            ""
          )
        }
      )
    },
    buttons: a!buttonLayout(
      primaryButtons: a!buttonWidget(
        label: "Submit",
        submit: true
      )
    )
  )
)

July 31, 2022

thank you that helped [mention:7ebed21b7ce742a999462e50d580ed48:e9ed411860ed4f2ba0265705b8793d05]