Date validation

Certified Senior Developer

I know this may sound little trivial but I couldn't figure out the logic.

I want a button should be enabled before 5 calendar days from the last date of the month to the first 3 calendar days of next month.

Example from if it's Aug, then it should enable on 26 Aug and stay enabled until 3 Sept.

Any help appreciated.

  Discussion posts and replies are publicly visible

  • Try this.  Since today is Aug 3, it will be enabled, toggle the commenting on lines 2 and 3 to see how it would act tomorrow (disabled):

    a!localVariables(
      local!date: today(),
      /*local!date: today()+1,*/
      local!daysInMonth: daysinmonth(month(local!date),year(local!date)),
      local!day: day(local!date),
      local!dayDisabledStart: 3,
      local!dayDisabledEnd: local!daysInMonth-5,
      {
        a!buttonArrayLayout(
          align: "START",
          buttons: {
            a!buttonWidget(
              label: "Button",
              disabled: not(
                or(
                  local!day<=local!dayDisabledStart,
                  local!day>=local!dayDisabledEnd,
                )
              )
            )
          }
        )
      }
    )

  • 0
    Certified Senior Developer

    Hey varun, Could you please the attached code once please

    a!localVariables(
      /*your actual date*/
      local!data:today()-7,
      /*getting last 5th date of the month*/
      local!startDate: eomonth(local!data,0)-5,
       /*from the last 5th date adding 8 to go to next month's 3rd day*/
      local!endDate:local!startDate+8,
      
      a!buttonLayout(
        showWhen: and(
          local!startDate<today(),
          today()<local!endDate
        ),
        primaryButtons: {
          a!buttonWidget(
            label:"Submit"
          )
        }
      )
    )

  • 0
    Certified Senior Developer
    in reply to Deepak gupta

    I am so sorry, for disable please try this code.

    a!localVariables(
      /*your actual date*/
      local!data: today() - 7,
      /*getting last 5th date of the month*/
      local!startDate: eomonth(local!data, 0) - 5,
      /*from the last 5th date adding 8 to go to next month's 3rd day*/
      local!endDate: local!startDate + 8,
      a!buttonLayout(
        primaryButtons: {
          a!buttonWidget(
            label: "Submit",
            disabled: not(
              and(
                local!startDate < today(),
                today() < local!endDate
              )
            )
          )
        }
      )
    )

  • 0
    Certified Senior Developer
    in reply to Chris

    That works perfectly, thanks