web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Preventing SharePointI...
Power Apps
Answered

Preventing SharePointIntegration Form Submission with Invalid Date Range

(1) ShareShare
ReportReport
Posted on by 143

Hi everyone!
I need to prevent users from submitting a form (SharePointIntegration) where the "End Date" (DataCardValue7) is earlier than the "Start Date" (DataCardValue6). Both are date pickers.


foro powerapps.jpg

Currently, I've added the following expression to the "OnChange" property of DataCardValue7:

If (

   DataCardValue7.SelectedDate < DataCardValue6.SelectedDate,
   Set(varError, "The end date cannot be earlier than the start date.");
   Notify(

            varError,
            NotificationType.Error,
            5000
            ),
DataCardValue7.SelectedDate >= DataCardValue6.SelectedDate,
Set(varError,"")
)

 

The issue is that users can still submit the form because it doesn't have an "OnSave" property where I can add code to control submission based on date errors. What can I do to prevent form submission with invalid dates?

Thank you in advance for any help you can provide.

 

 

 

Categories:
I have the same question (0)
  • Daniel Bocklandt Profile Picture
    5,151 Super User 2026 Season 1 on at

    Hey @FlowFalcon 

     

    Just put the code control in your submit button with an If Statement. If it's not okay don't save it. You could even Block the button from being clickable if the end Date it smaller than start Date. 

     

  • WarrenBelz Profile Picture
    156,100 Most Valuable Professional on at

    Hi @FlowFalcon ,

    Make the Required property of the Data Card true, then OnChange of DataCardValue7 put

    If(
     Self.SelectedDate < DataCardValue6.SelectedDate,
     Notify(
     "End Day cannot be before Start Day",
     NotificationType.Error
     );
     Reset(Self)
    )

    If the date is before, it will clear the value and as it is a required field, will not allow submission of the Form.

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    MVP (Business Applications)   Visit my blog Practical Power Apps

     

     

     

  • FlowFalcon Profile Picture
    143 on at

    Hi @WarrenBelz 
    Thank you so much for your willingness to help!
    I had already tried the code you sent me, but the Reset(Self) function doesn't clear the value of the date picker.
    I understand that in Power Apps, you can't reset and leave it blank (I might be wrong, as I'm a novice).

    Additionally, I didn't realize that the "OnSave" property was available in "SharePointIntegration", so I added the following:

     

    If(
     DataCardValue7.SelectedDate >= DataCardValue6.SelectedDate, 
     SubmitForm(SharePointForm1), 
     Notify("ERROR: End date cannot be earlier than start date.", NotificationType.Error)
    )

     

     

    Since we're here, can I ask you another question, or should I open a new topic? It's about the form header (Vacation Header) —I need it to remain fixed and not disappear when scrolling. Is this possible with SharePointIntegration forms?

    Thank you very much in advance.
    foro powerapps.jpg

     



  • Sam_Fawzi Profile Picture
    943 Super User 2026 Season 1 on at

    Hey,

     

    Instead of resetting Self, reset either DataCardValue7 or DataCardValue6, depending on where you are adding the code.

  • Verified answer
    WarrenBelz Profile Picture
    156,100 Most Valuable Professional on at

    Hi @FlowFalcon ,

    I assumed from your post that OnSave was not working for you (which often happens) hence the alternative. In answer to your second question, put it in a Label above the Form instead of in the Form.

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    MVP (Business Applications)   Visit my blog Practical Power Apps

     

  • FlowFalcon Profile Picture
    143 on at

    Hi @WarrenBelz 
    Starting from the fact that I am a novice with programming and with Power Automate, I had forgotten that the SharePointIntegration object had the OnNew, OnSave, etc. events... my bad...

    In the end, I added a condition in the OnSave event that controls both date pickers.

    Thank you very much for your help!

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 325 Most Valuable Professional

#2
11manish Profile Picture

11manish 165

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 88 Super User 2026 Season 1

Last 30 days Overall leaderboard