cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
pword
Helper IV
Helper IV

Disable Submit button for Current Date

Hi All, I want to disable my button if user selected current date.  Except for Emergency leave type and Sick leave . Can you help me with this?

 

Here's my code for my submit button in displaymode properties

 

 

 

 

With(
    {
        wLeave: Leavetype.Selected.Value,
        wLeaveAmt: Value(TextInput2_9.Text),
        wSLQualified: ContacVar.'Sick Qualified'.Value,
        wPLQualified: ContacVar.'Paternity Qualified'.Value,
        wMLQualified: ContacVar.'Maternity Qualified'.Value,
        wSPQualified: ContacVar.'SP Qualified'.Value,
        wBLQualified: ContacVar.'Bereavement Qualified'.Value,
        wVAWCQualified: ContacVar.'VAWC Qualified'.Value,
        wVLQualified: ContacVar.'Vacation Qualified'.Value,
        wSPWQualified: ContacVar.'SPW Qualified'.Value,
        wELQualified: ContacVar.'Vacation Qualified'.Value,
        DaysToStart: DateDiff(
            Today(),
            StartDates.SelectedDate,
            Days
        ),
        TotalDays: DateDiff(
            StartDates.SelectedDate,
            EndDates.SelectedDate,
            Days
        )
    },
    If(
        !'SLDCC Leave Form'.Valid || wLeave = "Vacation Leave" && (wVLQualified = "No" || wLeaveAmt > Value(TextInput1_9.Text)) || wLeave = "Emergency Leave" && (wELQualified = "No" || wLeaveAmt > Value(TextInput1_9.Text)) || wLeave = "Sick Leave" && (wSLQualified = "No" || wLeaveAmt > Value(TextInput1_9.Text)) || wLeave = "Paternity leave" && (wPLQualified = "No") || wLeave = "Maternity leave" && (wMLQualified = "No" || wLeaveAmt > Value(TextInput1_21.Text)) || wLeave = "Bereavement Leave" && (wBLQualified = "No" || wLeaveAmt > Value(TextInput1_24.Text)) || wLeave = "Leave for Victim of Violence (Women&Children)" && (wVAWCQualified = "No" || wLeaveAmt > Value(TextInput1_27.Text)) || wLeave = "Parental Leave for Solo Parent" && (wSPQualified = "No" || wLeaveAmt > Value(TextInput1_18.Text)) || wLeave = "Special Leave for Women" && (wSPWQualified = "No" || wLeaveAmt > Value(TextInput1_30.Text)) || (EndDates.SelectedDate < StartDates.SelectedDate) || If(
            Leavetype.Selected.Value = "Emergency Leave" || TotalDays < 2 || DaysToStart >= 5,
            DisplayMode.Edit,
            DisplayMode.Disabled
        ),
        DisplayMode.Disabled,
        DisplayMode.Edit
    )
)

 

 

 

 

disable.PNG

 

@StalinPonnusamy 

1 ACCEPTED SOLUTION

Accepted Solutions
StalinPonnusamy
Super User
Super User

Hi @pword 

 

Please try this

 

With(
    {
        wLeave: Leavetype.Selected.Value,
        wLeaveAmt: Value(TextInput2_9.Text),
        wSLQualified: ContacVar.'Sick Qualified'.Value,
        wPLQualified: ContacVar.'Paternity Qualified'.Value,
        wMLQualified: ContacVar.'Maternity Qualified'.Value,
        wSPQualified: ContacVar.'SP Qualified'.Value,
        wBLQualified: ContacVar.'Bereavement Qualified'.Value,
        wVAWCQualified: ContacVar.'VAWC Qualified'.Value,
        wVLQualified: ContacVar.'Vacation Qualified'.Value,
        wSPWQualified: ContacVar.'SPW Qualified'.Value,
        wELQualified: ContacVar.'Vacation Qualified'.Value,
        DaysToStart: DateDiff(
            Today(),
            StartDates.SelectedDate,
            Days
        ),
        TotalDays: DateDiff(
            StartDates.SelectedDate,
            EndDates.SelectedDate,
            Days
        )
    },
    If(
        !'SLDCC Leave Form'.Valid || wLeave = "Vacation Leave" && (wVLQualified = "No" || wLeaveAmt > Value(TextInput1_9.Text)) || wLeave = "Emergency Leave" && (wELQualified = "No" || wLeaveAmt > Value(TextInput1_9.Text)) || wLeave = "Sick Leave" && (wSLQualified = "No" || wLeaveAmt > Value(TextInput1_9.Text)) || wLeave = "Paternity leave" && (wPLQualified = "No") || wLeave = "Maternity leave" && (wMLQualified = "No" || wLeaveAmt > Value(TextInput1_21.Text)) || wLeave = "Bereavement Leave" && (wBLQualified = "No" || wLeaveAmt > Value(TextInput1_24.Text)) || wLeave = "Leave for Victim of Violence (Women&Children)" && (wVAWCQualified = "No" || wLeaveAmt > Value(TextInput1_27.Text)) || wLeave = "Parental Leave for Solo Parent" && (wSPQualified = "No" || wLeaveAmt > Value(TextInput1_18.Text)) || wLeave = "Special Leave for Women" && (wSPWQualified = "No" || wLeaveAmt > Value(TextInput1_30.Text)) || (EndDates.SelectedDate < StartDates.SelectedDate), 
DisplayMode.Disabled,     If(
        wLeave = "Emergency Leave" || wLeave = "Sick Leave" || (DaysToStart > 0 && (TotalDays < 3 || DaysToStart >= 5)),
        DisplayMode.Edit,
        DisplayMode.Disabled
    ))

 

View solution in original post

2 REPLIES 2
StalinPonnusamy
Super User
Super User

Hi @pword 

 

Please try this

 

With(
    {
        wLeave: Leavetype.Selected.Value,
        wLeaveAmt: Value(TextInput2_9.Text),
        wSLQualified: ContacVar.'Sick Qualified'.Value,
        wPLQualified: ContacVar.'Paternity Qualified'.Value,
        wMLQualified: ContacVar.'Maternity Qualified'.Value,
        wSPQualified: ContacVar.'SP Qualified'.Value,
        wBLQualified: ContacVar.'Bereavement Qualified'.Value,
        wVAWCQualified: ContacVar.'VAWC Qualified'.Value,
        wVLQualified: ContacVar.'Vacation Qualified'.Value,
        wSPWQualified: ContacVar.'SPW Qualified'.Value,
        wELQualified: ContacVar.'Vacation Qualified'.Value,
        DaysToStart: DateDiff(
            Today(),
            StartDates.SelectedDate,
            Days
        ),
        TotalDays: DateDiff(
            StartDates.SelectedDate,
            EndDates.SelectedDate,
            Days
        )
    },
    If(
        !'SLDCC Leave Form'.Valid || wLeave = "Vacation Leave" && (wVLQualified = "No" || wLeaveAmt > Value(TextInput1_9.Text)) || wLeave = "Emergency Leave" && (wELQualified = "No" || wLeaveAmt > Value(TextInput1_9.Text)) || wLeave = "Sick Leave" && (wSLQualified = "No" || wLeaveAmt > Value(TextInput1_9.Text)) || wLeave = "Paternity leave" && (wPLQualified = "No") || wLeave = "Maternity leave" && (wMLQualified = "No" || wLeaveAmt > Value(TextInput1_21.Text)) || wLeave = "Bereavement Leave" && (wBLQualified = "No" || wLeaveAmt > Value(TextInput1_24.Text)) || wLeave = "Leave for Victim of Violence (Women&Children)" && (wVAWCQualified = "No" || wLeaveAmt > Value(TextInput1_27.Text)) || wLeave = "Parental Leave for Solo Parent" && (wSPQualified = "No" || wLeaveAmt > Value(TextInput1_18.Text)) || wLeave = "Special Leave for Women" && (wSPWQualified = "No" || wLeaveAmt > Value(TextInput1_30.Text)) || (EndDates.SelectedDate < StartDates.SelectedDate), 
DisplayMode.Disabled,     If(
        wLeave = "Emergency Leave" || wLeave = "Sick Leave" || (DaysToStart > 0 && (TotalDays < 3 || DaysToStart >= 5)),
        DisplayMode.Edit,
        DisplayMode.Disabled
    ))

 

Thank you @StalinPonnusamy  its working .😀 but I put some code to apply it to my unpaid leave but didn't work. The submit should be disable because of the unpaid  selected date

 

Heres my code:

 

 

With(
    {
        wLeave: Leavetype.Selected.Value,
        wLeaveAmt: Value(TextInput2_9.Text),
        wSLQualified: ContacVar.'Sick Qualified'.Value,
        wPLQualified: ContacVar.'Paternity Qualified'.Value,
        wMLQualified: ContacVar.'Maternity Qualified'.Value,
        wSPQualified: ContacVar.'SP Qualified'.Value,
        wBLQualified: ContacVar.'Bereavement Qualified'.Value,
        wVAWCQualified: ContacVar.'VAWC Qualified'.Value,
        wVLQualified: ContacVar.'Vacation Qualified'.Value,
        wSPWQualified: ContacVar.'SPW Qualified'.Value,
        wELQualified: ContacVar.'Vacation Qualified'.Value,
        DaysToStart: DateDiff(
            Today(),
            StartDates.SelectedDate,
            Days
        ),
        TotalDays: DateDiff(
            StartDates.SelectedDate,
            EndDates.SelectedDate,
            Days
        ),
        DaysToStartUnpaid: DateDiff(
            Today(),
            StartDateUnpaid.SelectedDate,
            Days
        ),
        TotalUnpaidDays: DateDiff(
            StartDateUnpaid.SelectedDate,
            EndDateUnpaid.SelectedDate,
            Days
        )
    },
    If(
        !'SLDCC Leave Form'.Valid || wLeave = "Vacation Leave" && (wVLQualified = "No" || wLeaveAmt > Value(TextInput1_9.Text)) || wLeave = "Emergency Leave" && (wELQualified = "No" || wLeaveAmt > Value(TextInput1_9.Text)) || wLeave = "Sick Leave" && (wSLQualified = "No" || wLeaveAmt > Value(TextInput1_9.Text)) || wLeave = "Paternity leave" && (wPLQualified = "No") || wLeave = "Maternity leave" && (wMLQualified = "No" || wLeaveAmt > Value(TextInput1_21.Text)) || wLeave = "Bereavement Leave" && (wBLQualified = "No" || wLeaveAmt > Value(TextInput1_24.Text)) || wLeave = "Leave for Victim of Violence (Women&Children)" && (wVAWCQualified = "No" || wLeaveAmt > Value(TextInput1_27.Text)) || wLeave = "Parental Leave for Solo Parent" && (wSPQualified = "No" || wLeaveAmt > Value(TextInput1_18.Text)) || wLeave = "Special Leave for Women" && (wSPWQualified = "No" || wLeaveAmt > Value(TextInput1_30.Text)) || (EndDates.SelectedDate < StartDates.SelectedDate),
        DisplayMode.Disabled,
        If(
            wLeave = "Emergency Leave" || wLeave = "Sick Leave" || (DaysToStart > 0 && (TotalDays < 3 || DaysToStart >= 5)) || (DaysToStartUnpaid > 0 && (TotalUnpaidDays < 3 || DaysToStartUnpaid >= 5)),
            DisplayMode.Edit,
            DisplayMode.Disabled
        )
        
    )
)

 

 

 

unpaid.PNG

 

@StalinPonnusamy 

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on June 15, 2022 at 8am PDT.

PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

Top Solution Authors
Top Kudoed Authors
Users online (1,629)