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 / Validation before navi...
Power Apps
Unanswered

Validation before navigating

(0) ShareShare
ReportReport
Posted on by

Hello, 

 

I'm having trouble getting running thru some IFs statements before navigating to the next screen. 

 

I have the following IF statements and i want them to validate before allowing it to continue. 

 

If(Weekday(BusinessDay_DatePicker.SelectedDate) in ColWeekDays, Notify("You selected a Friday", NotificationType.Success), Notify("Date must be Friday", NotificationType.Error));

If(IsBlank(LookUp(Timesheet_Entries_T,'Employee Name'=User().FullName And WeekEnding = BusinessDay_DatePicker.SelectedDate)), Notify("Timesheet already exists for the selected weekending please go to edit timesheet menu",NotificationType.Error));

Navigate(TimeCardNew,ScreenTransition.Cover)

Categories:
I have the same question (0)
  • Ami K Profile Picture
    15,687 Super User 2024 Season 1 on at

    @jubae22 , 

    As I understand it, if the selected business day is a Friday, then display a notification to the user that Friday has been selected. If Friday has not been selected, then return an error message informing the user that the date should be Friday. The rest of the expression should not proceed any further at this point.

     

    However, if this condition has passed, then the subsequent check is to validate if the selected date, together with the selected name, has already been submitted as a record in your table. If that is the case, then return an error and do not proceed any further.

     

    If all checks are passed, then allow the user to proceed to the target screen.

     

    Is that correct?

  • CU30071822-0 Profile Picture
    on at

    That is 100% Correct @Amik 😁

  • Ami K Profile Picture
    15,687 Super User 2024 Season 1 on at

    Hi @jubae22 ,

    You could try the expression below. Note I have assumed the 'Employee Name' field is a Text field rather than a SharePoint or Dataverse People field.

    If(
     Weekday(BusinessDay_DatePicker.SelectedDate) in ColWeekDays,
     If(
     IsBlank(
     LookUp(
     Timesheet_Entries_T,
     'Employee Name' = User().FullName And WeekEnding = BusinessDay_DatePicker.SelectedDate
     )
     ),
     Notify(
     "You selected a Friday",
     NotificationType.Success
     );
     Navigate(
     TimeCardNew,
     ScreenTransition.Cover
     ),///ELSE
     Notify(
     "Timesheet already exists for the selected weekending please go to edit timesheet menu",
     NotificationType.Error
     )
     ),///ELSE
     Notify(
     "Date must be Friday",
     NotificationType.Error
     )
    );

     

    One observation - if the purpose of ColWeekDays is only to return a list of Friday dates, you could exclude the collection and instead use a slight variation of above expression below:

     

    If(
     Weekday(
     DateValue(BusinessDay_DatePicker.SelectedDate),
     StartOfWeek.Monday
     ) = 5,
     If(
     IsBlank(
     LookUp(
     Timesheet_Entries_T,
     'Employee Name' = User().FullName And WeekEnding = BusinessDay_DatePicker.SelectedDate
     )
     ),
     Notify(
     "You selected a Friday",
     NotificationType.Success
     );
     Navigate(
     TimeCardNew,
     ScreenTransition.Cover
     ),///ELSE
     Notify(
     "Timesheet already exists for the selected weekending please go to edit timesheet menu",
     NotificationType.Error
     )
     ),///ELSE
     Notify(
     "Date must be Friday",
     NotificationType.Error
     )
    );

     

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

     

    If I have answered your question, please mark your post as Solved. Remember, you can accept more than one post as a solution

    If you like my response, please give it a Thumbs Up.

  • CU30071822-0 Profile Picture
    on at

    Hi Amik ,

     

    Thank you for your response. Both syntax worked great for validating if the selected date is a Friday and not allowing it to go to the next screen if its anything other than a Friday. The only issue now is that it is not validating if a record with the selected week ending already exists and restricting it from navigating to the next screen. I selected a week ending that already exists in my Timesheet_Entries_T table and it allows me to navigate to the next screen. 

     

    this part not working: 

     

    IsBlank(
     LookUp(
     Timesheet_Entries_T,
     'Employee Name' = User().FullName And WeekEnding = BusinessDay_DatePicker.SelectedDate
  • Ami K Profile Picture
    15,687 Super User 2024 Season 1 on at

    Hi @jubae22 - this works for me.

     

    • Do you receive an error message? If so, could you take a screenshot of the error message.

    • Are you sure the 'Employee Name' field is a Text field and not a People field?

    • Are you sure the Employee Name field can match the output of User().FullName? For example suppose you have "J Smith" for an Employee Name, but User().FullName returns "John Smith".

     

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

     

    If I have answered your question, please mark your post as Solved. Remember, you can accept more than one post as a solution

    If you like my response, please give it a Thumbs Up.

  • CU30071822-0 Profile Picture
    on at

    Hi Amir,

     

    I didnt get an error message but my app allowed me to continue to the next screen even though i selected a week ending that already exists in the timesheet entries table. 

     

    The employee name is a text field and my code is patching User().Fullname directly into that field.

     

    jubae22_0-1685119307072.pngjubae22_1-1685119455673.png

     

  • Ami K Profile Picture
    15,687 Super User 2024 Season 1 on at

    Hi @jubae22 ,

     

    Potentially the problem relates to my 3rd point. I note in your image for Employee Names, you have a fully capitalised name: JULIA BATRES.

     

    User().FullName could be returning the user's name in Proper format (capitalised initials): Julia Batres. I note you said this is occurring in your patch but is it happening for all users? To confirm this is the case, add a Label somewhere in your form and in the Text property, enter User().FullName.

     

    JULIA BATRES does not equal Julia Batres, thus the expression does not think an existing entry for the selected date exists.

     

    If you do not want to update the employee name field in a Proper format so that it matches the output of the User function, you could wrap the User function with an Upper function to capitalize each letter, e.g.:

     

     

    Upper(User().FullName)

     

     

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

     

    If I have answered your question, please mark your post as Solved. Remember, you can accept more than one post as a solution

    If you like my response, please give it a Thumbs Up.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Vish WR Profile Picture

Vish WR 762

#2
11manish Profile Picture

11manish 640

#3
Valantis Profile Picture

Valantis 548

Last 30 days Overall leaderboard