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

Two if conditions on Submit form button

Hi,

I am trying to validate two conditions while submitting form but I am unable to do so. Not sure what the error is 

 

If(
    DateValue2.SelectedDate < Today() Or Weekday(DateValue2.SelectedDate) = 1 Or Weekday(DateValue2.SelectedDate) = 7 Or DateValue2.SelectedDate > varDate,
    Set(
        varMessage,
        "Please select a date within 3 business days"
    ),
    And(
        CountRows(DataCardValue12.Attachments) < 0,
        Notify(
            "Attachment Missing",
            NotificationType.Error
        )
    ),
    SubmitForm(FormNewRequest);
    Set(
        varMessage,
        " "
    )
)

 

 

First Condition is working fine as that was the only one before. I am trying to add attachment validation now. But it is not working as expected.

 

Regards,

1 ACCEPTED SOLUTION

Accepted Solutions

Try:

If(DateValue2.SelectedDate < Today() Or Weekday(DateValue2.SelectedDate) = 1 Or

Weekday(DateValue2.SelectedDate) = 7 Or DateValue2.SelectedDate > varDate,

Notify("Please select a requested start date at least 3 days from today", NotificationType.Error),

If(CountRows(DataCardValue12.Attachments) < 0,

Notify("Attachment Missing"), SubmitForm(FormNewRequest)))

------------

If you like this post, give a Thumbs up. Where it solved your request,

Mark it as a Solution to enable other users find it.

 

 

View solution in original post

5 REPLIES 5
Super User III
Super User III

Try:

If(DateValue2.SelectedDate < Today() Or Weekday(DateValue2.SelectedDate) = 1 Or Weekday(DateValue2.SelectedDate) = 7 Or      DateValue2.SelectedDate > varDate Or

CountRows(DataCardValue12.Attachments) < 0,

 Notify("Please select a date within 3 business days Or Attachment Missing"), SubmitForm(FormNewRequest))

------------

If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

Thanks ! This works, I had checked it before also. But I need to show different error messages for both the fields. 

Try:

If(DateValue2.SelectedDate < Today() Or Weekday(DateValue2.SelectedDate) = 1 Or

Weekday(DateValue2.SelectedDate) = 7 Or DateValue2.SelectedDate > varDate,

Notify("Please select a requested start date at least 3 days from today", NotificationType.Error),

If(CountRows(DataCardValue12.Attachments) < 0,

Notify("Attachment Missing"), SubmitForm(FormNewRequest)))

------------

If you like this post, give a Thumbs up. Where it solved your request,

Mark it as a Solution to enable other users find it.

 

 

View solution in original post

Thanks eka24, this works 🙂

There is a correction in the attachment section, it should be 

If(CountRows(DataCardValue12.Attachments) < 1

For anyone in future to use. 

Opened a new post.

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Community Highlights

Community Highlights

Check out the Power Platform Community Highlights

Top Solution Authors
Top Kudoed Authors
Users online (7,849)