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 / After patching gallery...
Power Apps
Answered

After patching gallery items to sharepoint list, I cannot reset the DatePicker

(0) ShareShare
ReportReport
Posted on by 187

Hi all, 

Been wrapping my head around the following situation but can't seem to solve it.
On my screen I have a form, which contains a datefield and two textinput fields. All good.

Next I have a vertical gallery containing articles a user can select by checking a checkbox.

Upon check, the article is stored in a collection.
I have a second blank gallery which shows the articles from the collection. It contains an text label to show the article name.
Some articles need to receive a Best Before date, so in the edit gallery I have inserted a date picker to select the best before date.

Once that is done, I save the form with a save button submitform and in the onsuccess property of the form I patch the article name and bestbefore date to a Sharepoint list.

When I go back to my previous screen, then select a new session to record articles with best before dates, the BestBefore.SelectedDate still shows the date which I patched to Sharepoint.
I want that SelectedDate to be Blank after the patch but I can't seem to manage that.

Reset does not work if it's outside of the gallery, if I insert a button in the gallery and set the onselect to Reset it still does not work.
I put a text label in the gallery to show the selecteddate. Strangely it shows the date from the patched record, but if I evaluate the textlabel it shows BestBeforeDate.SelectedDate is Blank...
That's why the error message I included below the date field to show Date missing in case selected date is Blank is also not working since it seems to think it's still somewhere. See also picture.

Any idea how to tackle this? End goal is that I make the user aware that a Best Before date still needs to be added if it's empty.

Schermafbeelding 2023-04-15 161011.png
To make it even more strange, If I select my textlabel where I have the error text to populate and e.g. remove the most right closing ) and then type the ) again, the error message pops up again.
Seems to be some timing thingy but no clue. Anyone?

Categories:
  • JohnM86 Profile Picture
    590 on at

    It sounds like the issue you're experiencing is due to the fact that the BestBefore.SelectedDate variable is not being reset properly after the form is submitted and the data is patched to SharePoint. Here's one possible solution to try:

     

    Add a Reset function to the OnSuccess property of the form, after the Patch statement. This will reset the BestBefore.SelectedDate variable to blank after the form is submitted and the data is patched to SharePoint.

     

    OnSuccess: {
    Patch(...),
    Reset(BestBefore)
    }

     

    Add a Reset function to the OnSelect property of the checkbox that clears the selected article from the collection. This will ensure that the BestBefore.SelectedDate variable is also cleared when the user unchecks the article.

     

    OnSelect: {
    Remove(SelectedArticles, ThisItem),
    Reset(BestBefore)
    }

     

    Make sure that the Default property of the date picker in the Edit gallery is set to BestBefore.SelectedDate, and not to the value of the patched record.

     

    Default: BestBefore.SelectedDate

     

    By resetting the BestBefore.SelectedDate variable in both the OnSuccess property of the form and the OnSelect property of the checkbox, you should be able to ensure that it is always blank when the user returns to the form. Additionally, setting the Default property of the date picker to BestBefore.SelectedDate should ensure that the user sees the correct value when they edit an existing article.

  • debarbanson Profile Picture
    187 on at

    Hi @JohnM86 ,

    Many thanks for reaching out. Unfortunately this does not work.
    The Reset function can only be used with a resettable control. Controls within a Form or Gallery control can only be reset from within the same form or gallery template is the error message I receive.

    Message pops up both if I try it in the OnSucces property of the form but also in the Oncheck/Uncheck version of my first gallery.

    I cannot set the Default Date to BestBefore.SelectedDate since that would create a circular reference.

    So I am a bit puzzled where and how to reset the BestBeforeSelectedDate. Been puzzling on this for hours now 😞

  • JohnM86 Profile Picture
    590 on at

    Could you try : set(variable, Blank()); with variable being the variable name

  • debarbanson Profile Picture
    187 on at

    Hi @JohnM86 you mean in the Default date of the date picker?

  • JohnM86 Profile Picture
    590 on at

    what is the default property of your bestbefore date picker and the patch function you are using ?

     

  • debarbanson Profile Picture
    187 on at

    @JohnM86  the default property of the date picker is empty. The patch function is as follows:

    Notify("Session is successfully booked",NotificationType.Success,10000);
    ForAll(Gallery2.AllItems,
    Patch(InkSessions,Defaults(InkSessions),{Title: "-", ClientNr: varSelectedClient, Date:Last(Sessions).Date,BrandName: lblBrandName.Text, BrandDescription: lblBrandDescription.Text, Batch: InputBatch.Text, LOT: InputLOT.Text,BestBefore: BestBeforeDate.SelectedDate, Supplier: InputSupplier.Text, Identifier: Last(Sessions).ID}));

  • JohnM86 Profile Picture
    590 on at

    Could you try set the default property to 'Today()' which should default it back to the current date. 

     

     

  • JohnM86 Profile Picture
    590 on at

    or in fact DefaultDate - Blank()

  • JohnM86 Profile Picture
    590 on at

    once you have default Blank() - on the pages visible property use Reset(DatePicker);

  • debarbanson Profile Picture
    187 on at

    tried both but to no avail. If I blank it, it will still somehow remember the patched date and as such the message Date missing is not popping up.

    If I put it on Today(), it will automatically pick up today's date and as such also the message Date missing is not showing up. Since we require the user to fill in a date, it needs to be empty.
    BTW thanks for thinking along!

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

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 339 Super User 2026 Season 2

#2
M Bilal Khan Profile Picture

M Bilal Khan 289

#3
Mohsin Ali Profile Picture

Mohsin Ali 228

Last 30 days Overall leaderboard