cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Mays
Level: Powered On

How to make powerapps prevent user from requesting a leave that already booked by him?

I need your help to prevent powerapps submitting the days of a new leave request if it is already booked by the employee

without using the built-in leave template ... the problem is my app not saving the specific days of the leave only the numbers of the days to subtract it from the quota,,,

 

Please any help would be highly appreciated

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: How to make powerapps prevent user from requesting a leave that already booked by him?

Hi @Mays ,

Based on the issue that you mentioned, I think this issue may be related to the '=' operator within the formula I provided above.

 

Please consider modify your formula as below:

If(
   !IsBlank(    /* <-- Check if the same Leave Request submitted from current sign in user is already existed in your data source */ 
            LookUp(LeaveList, From <= DataCardValue19.SelectedDate && To <= DataCardValue20.SelectedDate && DataCardValue4.Selected.Email = Leave_x002d_Employee.Email)
   ),
   Notify("The days from " & DataCardValue19.SelectedDate & " to " & LookUp(LeaveList, From <= DataCardValue19.SelectedDate && To <= DataCardValue20.SelectedDate && DataCardValue4.Selected.Email = Leave_x002d_Employee.Email).To & " has been booked!", NotificationType.Error),
   SubmitForm(LeaveDetailsForm)
)

Please consider take a try with above solution, then check if the issue is solved.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
9 REPLIES 9
Super User
Super User

Re: How to make powerapps prevent user from requesting a leave that already booked by him?

I don't see any way to do this unless you store at least the starting date of the leave in your data source in addition to the number of days. Without storing a specific date you have nothing you can check new entries against.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
Community Support Team
Community Support Team

Re: How to make powerapps prevent user from requesting a leave that already booked by him?

Hi @Mays ,

Could you please share a bit more about your scenario?

Could you please show more details about the data source you used to store the submitted Leave Request?

 

I assume that you have added corresponding columns (StartDate, EndDate and Requester) in your data source to store the New Leave Request Detail.

The StartDate column is used to store the Start date of the new Leave request, the EndDate column is used to store the End date of the new Leave request, the Requester column used to store the display name of the user who submit this Leave Request.

 

If you want to prevent powerapps submitting the days of a new leave request if it is already booked by the employee, I have made a test on my side, please take a try with the following workaround:

Set the OnSelect property of the "Submit" button to following:

If(
   !IsBlank(    /* <-- Check if the same Leave Request submitted from current sign in user is already existed in your data source */ 
LookUp('YourDataSource', StartDate = StartDatePicker.SelectedDate && EndDate = EndDatePicker.SelectedDate && Requester = User().FullName)
), Notify("Your have submitted same Leave Request, please do not submit repeatedly!", NotificationType.Error), Patch( /* <-- Submit new Leave Request */ 'YourDataSource', Defaults('YourDataSource'), { StartDate: StartDatePicker.SelectedDate, EndDate: EndDatePicker.SelectedDate, Requester: User().FullName,
... } ) )

Please take a try with above solution, then check if the issue is solved.

Note: On your side, you could search the submitted Leave Requests within your data source based on the new Leave Request before submitting, check if there is already a record submitted from you existed in your data source.

 

More details about the LookUp function and Patch function, please check the following article:

LookUp function, Patch function

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Mays
Level: Powered On

Re: How to make powerapps prevent user from requesting a leave that already booked by him?

Thank you @Pstork1 , @v-xida-msft  for your reply ,I already did this in my sharepoint list as attached ,

but for example if employee request a leave for the days from 10-Jun to 13-Jun the datasource will capture the start,end and the number of days ...that mean if this employee by mistake submitted a new leave request for the days for example from 12-Jun to 15-Jun ,

In this case the app should through an error "you already have a leave for the day 12 and 13 of Jun" (it is already booked)

 

I hope you get my point and sorry if i didn't explain it clearly

Mays
Level: Powered On

Re: How to make powerapps prevent user from requesting a leave that already booked by him?

@v-xida-msft  I will try this solution and get back to you very soon ... Thanks

Community Support Team
Community Support Team

Re: How to make powerapps prevent user from requesting a leave that already booked by him?

Hi @Mays ,

Have you solved your problem?

 

If you have solved your problem, please go ahead to click "Accept as Solution" to identify this thread has been solved.

 

If you have any questions when using formulas in PowerApps, please feel free to reply here.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Mays
Level: Powered On

Re: How to make powerapps prevent user from requesting a leave that already booked by him?

Hi @v-xida-msft  ,,, I changed it slightly to fit with my datasource , I requested leaves from 14/06 to 16/06 then I tryed to apply the days from 15/06 to 17/06 that should give an error for the days 15 and 16 but the app saved it successfuly !!

If(
   !IsBlank(    /* <-- Check if the same Leave Request submitted from current sign in user is already existed in your data source */ 
            LookUp(LeaveList, From = DataCardValue19.SelectedDate && To = DataCardValue20.SelectedDate && DataCardValue4.Selected.Email = Leave_x002d_Employee.Email)
           ),
   Notify("Your have submitted same Leave Request, please do not submit repeatedly!", NotificationType.Error),
   SubmitForm(LeaveDetailsForm)
)
Super User
Super User

Re: How to make powerapps prevent user from requesting a leave that already booked by him?

YOur logic only checks whether it has the same start and end dates.  I think you need to change the '=' in your test to '>='  for the start and '<=' for the end.  Otherwise you won't catch dates that fall in the middle.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
Community Support Team
Community Support Team

Re: How to make powerapps prevent user from requesting a leave that already booked by him?

Hi @Mays ,

Based on the issue that you mentioned, I think this issue may be related to the '=' operator within the formula I provided above.

 

Please consider modify your formula as below:

If(
   !IsBlank(    /* <-- Check if the same Leave Request submitted from current sign in user is already existed in your data source */ 
            LookUp(LeaveList, From <= DataCardValue19.SelectedDate && To <= DataCardValue20.SelectedDate && DataCardValue4.Selected.Email = Leave_x002d_Employee.Email)
   ),
   Notify("The days from " & DataCardValue19.SelectedDate & " to " & LookUp(LeaveList, From <= DataCardValue19.SelectedDate && To <= DataCardValue20.SelectedDate && DataCardValue4.Selected.Email = Leave_x002d_Employee.Email).To & " has been booked!", NotificationType.Error),
   SubmitForm(LeaveDetailsForm)
)

Please consider take a try with above solution, then check if the issue is solved.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Mays
Level: Powered On

Re: How to make powerapps prevent user from requesting a leave that already booked by him?

Thank you very much @v-xida-msft  & @Pstork1  I could solve my probelm because of your help

,Much appreciated 

Helpful resources

Announcements
firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

SecondImage

PowerApps Monthly Community Call

Next Wednesday, August 21st at 8am PDT

Top Community Contributors for July 2019

Top Community Contributors for July 2019

Let's thank our top community contributors

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

FifthImage

Dynamics 365 and Power Platform April 2019 Release notes

Features releasing from April 2019 through September 2019!

SixthImage

Power Summit Australia 2019

August 20-23rd 2019

Users Online
Currently online: 76 members 3,951 guests
Please welcome our newest community members: