I have a custom SharePoint List customised through PowerApps. I am facing two issues and wonder if someone could help here. The StartDate has a default value (today()) but EndDate don't.
OnStart of the FormScreen1, I have got the following varilable:
Set(vStartInvalidDate, false); Set(vEndInValidDate, false)
OnChange of the DatePicker, I have the following, to validate if selected date is in the past.
If(dpAccessStartDate.SelectedDate<Today(),Set(vStartInvalidDate, true ),Set(vStartInvalidDate, false ))
On Visible property for the Label:
Or(vStartInvalidDate, DisplayMode = Edit)
1) When I add a new entry, the form shows the error label on the for EndDate. How doI stop showing this error label until OnChange event fires?
2) Edit Form has entries which were valid at the time, but when I edit an item with past date, it shows the error label. I want to validate only OnChange event rather than on start with Edit or New form?
Is there a way to achieve this?
The OnVisible property of your Label should be:
If(And(vStartInvalidDate=true, Form1.DisplayMode = Edit),true,false)
@v-monli-msft Thanks for a response. I tried this still doesn't work. I am on SharePoint Form so assumed you meant SharePointForm1 rather than Form1.
If( And( vStartInvalidDate = true, SharePointForm1.DisplayMode = SharePointForm1.DisplayMode.Edit ), true, false )
I noticed that as soon as the Form gets visible, the value for my variable gets changed automatically to true if the selected date (in the existing item) in the edit form has past. Something is triggering 'OnChange' event without me asking...!
There is a known issue with Datepicker in SharePoint form where OnChange is being fired on load, without the user actually changing the date. Workaround is to only perform OnChange() event if the user actively selects a date, or if the form item has not changed (i.e. we haven't navigated to a new form item).
So change DatePicker OnChange function to something like:
If( (DataCardValue.SelectedDate <> SharePointForm.Current.ValueHoldingDate) || (lastFormItemID = SharePointForm.Current.ID), // put action here that should be performed on *real* OnChange ); Set( lastFormItemID, SharePointForm.Current.ID )
Check out the on demand sessions that are available now!
Stay up tp date on the latest blogs and activities in the community News & Announcements.
Features releasing from October 2020 through March 2021
Check out the Power Platform Community Highlights