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

Parents
  • 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"
          )
        }
      )
    )

Reply
  • 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"
          )
        }
      )
    )

Children
  • 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
              )
            )
          )
        }
      )
    )