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?
Thanks
Hi @smerchatn,
The OnVisible property of your Label should be:
If(And(vStartInvalidDate=true, Form1.DisplayMode = Edit),true,false)
Regards,
Mona
@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...!
@v-monli-msft, Any update on this, I need to know if this is possible or not so appreciate your help. Thanks
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 )
This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.
Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.
User | Count |
---|---|
204 | |
71 | |
51 | |
49 | |
20 |
User | Count |
---|---|
260 | |
121 | |
85 | |
75 | |
72 |