cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Taylor28
Helper I
Helper I

Limit User to One Entry a Day

Hello,

I have created a fairly simple Check In/Out app for my department thats connected to a  Sharepoint list. The user clicks the "Check In" or "Check Out" button and information is collected from the users office 365 profile(email,location etc). My question is it possible to limit the entry for each office 365 user once per day. So the user would only be able to check in and out once per day,perhaps an error message saying that they have already checked in for the day? Any help on this would be greatly appreciated.

 

Thank You.

2 ACCEPTED SOLUTIONS

Accepted Solutions
v-xida-msft
Community Support
Community Support

Hi @Taylor28 ,

Based on the needs that you mentioned, I think the LookUp function could achieve your needs.

 

I assume that there are two Date time type columns to store the CheckIn time and CheckOut time individually in your SP list -- "CheckInTime" & "CheckOutTime". Please take a try with the following workaround:

 

Set the OnStart property of App to following:

 

Set(CurrentUserEmail, User().Email)

 

 

Set the DisplayMode property of the "Check In" button to following formula:

 

If(
  !IsBlank(LookUp('Your SP List', 'Created By'.Email = CurrentUserEmail && Text(Created, DateTimeFormat.ShortDate) = Text(Today(), DateTimeFormat.ShortDate)).CheckInTime),
  DisplayMode.Disabled,
  DisplayMode.Edit
)

 

Set the DisplayMode property of the "Check Out" button to following:

 

If(
  !IsBlank(LookUp('Your SP List', 'Created By'.Email = CurrentUserEmail && Text(Created, DateTimeFormat.ShortDate) = Text(Today(), DateTimeFormat.ShortDate)).CheckOutTime),
  DisplayMode.Disabled,
  DisplayMode.Edit
)

 

 

Set the OnSelect property of "Check In" button to following:

 

Patch(
      'Your SP List',
      Defaults('Your SP List'),
      {
        Title: "xxxx",
        CheckInTime: Now()
      }
)

 

Set the OnSelect property of the "Check Out" button to following:

 

Patch(
      'Your SP List',
      LookUp('Your SP List', 'Created By'.Email = CurrentUserEmail && Text(Created, DateTimeFormat.ShortDate) = Text(Today(), DateTimeFormat.ShortDate)),
      {
        CheckOutTime: Now()
      }
)

 

Please take a try with above solution, then re-load your canvas app (fire the OnStart property of App), then check if the issue is solved.

Note: Please replace the CheckInTime and CheckOutTime with actual date time type column names from your SP list

 

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.

View solution in original post

Hi @Taylor28 ,

Within the formula I provided above, I do not use CountRows function. The formula I provided is not same that you mentioned. Have you taken a try with the formula I provided above (without CountRows() function)?

 

Based on the If formula that you mentioned above, I think there is something wrong with it. Please consider modify it as below:

If(
    CountRows(Filter('Employee Check In/Out', DateDiff(Created,Now(),Days)=0))>0,  // Modify frmula here
    Notify("You can't check in more than once per day",NotificationType.Error,1000),
    Patch(
          'Employee Check In/Out',
          Defaults('Employee Check In/Out'),
          {
            Title: "Check In",
            I_x0020_am_x0020_Feeling_x0020_W: If(Radio1.Selected.Value="No",false,true),
            maer: If(Radio2.Selected.Value="No",false,true),
            Location: Office365Users.MyProfileV2().officeLocation,
            pbsi:User().Email,
            Employee_x0020_Name: User().FullName,
            xcli: "Checked In",
            o5kf:Now()
          }
    );Navigate('Check In Success',ScreenTransition.Cover)
)     // do not miss close ')' here

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

 

In addition, please also take a try with the solution I provided above, check if it could help in your scenario.

 

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.

View solution in original post

6 REPLIES 6
KrishnaV
Community Champion
Community Champion

Hi @Taylor28 ,

 

You can validate the user check-in as follows, onSelect  property of the check-in button validate as below:

 

If(
   CountRows(
      Filter(
         SPListName,
         DateDiff(
            lastlogindate,
            Now(),
            Days
         )=0
      )>0
   ),
   Notify("You can't check-in more than once per day",NotificationType.Error,1000),
   Patch(SPListName,Defaults(SPListName),{userName:User().email,lastlogindate:now()})
)

 

Same we can do for check-out.


I hope this resolved your issue if you see any challenge/need further help please let me know I am always happy to help.

Regards,
Krishna
If this post helps give a 👍 and if it solved your issue consider Accept it as the solution to help the other members find it more.

 



I hope this resolved your issue if you see any challenge/need further help please let me know I am always happy to do it for my community.

Regards,
KrishnaV
Business Applications MVP, Microsoft Certified Trainer
Twitter | Linkedin | YouTube | GitHub
If this post helps you give a THUMS-UP and if it solved your issue consider Accept it as the solution to help the other members / new members of the community.

v-xida-msft
Community Support
Community Support

Hi @Taylor28 ,

Based on the needs that you mentioned, I think the LookUp function could achieve your needs.

 

I assume that there are two Date time type columns to store the CheckIn time and CheckOut time individually in your SP list -- "CheckInTime" & "CheckOutTime". Please take a try with the following workaround:

 

Set the OnStart property of App to following:

 

Set(CurrentUserEmail, User().Email)

 

 

Set the DisplayMode property of the "Check In" button to following formula:

 

If(
  !IsBlank(LookUp('Your SP List', 'Created By'.Email = CurrentUserEmail && Text(Created, DateTimeFormat.ShortDate) = Text(Today(), DateTimeFormat.ShortDate)).CheckInTime),
  DisplayMode.Disabled,
  DisplayMode.Edit
)

 

Set the DisplayMode property of the "Check Out" button to following:

 

If(
  !IsBlank(LookUp('Your SP List', 'Created By'.Email = CurrentUserEmail && Text(Created, DateTimeFormat.ShortDate) = Text(Today(), DateTimeFormat.ShortDate)).CheckOutTime),
  DisplayMode.Disabled,
  DisplayMode.Edit
)

 

 

Set the OnSelect property of "Check In" button to following:

 

Patch(
      'Your SP List',
      Defaults('Your SP List'),
      {
        Title: "xxxx",
        CheckInTime: Now()
      }
)

 

Set the OnSelect property of the "Check Out" button to following:

 

Patch(
      'Your SP List',
      LookUp('Your SP List', 'Created By'.Email = CurrentUserEmail && Text(Created, DateTimeFormat.ShortDate) = Text(Today(), DateTimeFormat.ShortDate)),
      {
        CheckOutTime: Now()
      }
)

 

Please take a try with above solution, then re-load your canvas app (fire the OnStart property of App), then check if the issue is solved.

Note: Please replace the CheckInTime and CheckOutTime with actual date time type column names from your SP list

 

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.

Hi Krishna,

Thank you for the quick reply. I tried this formula but received a few errors. It stated that the function IF and Count Rows has some invalid arguments,Expecting a number value, and expects ParenClose where Eof is expected. I also attached a screenshot. Thanks for your help on this!

 

If(CountRows(Filter('Employee Check In/Out',DateDiff(Created,Now(),Days)=0)>0),Notify("You can't check in more than once per day",NotificationType.Error,1000),Patch('Employee Check In/Out',Defaults('Employee Check In/Out'),{Title:"Check In",I_x0020_am_x0020_Feeling_x0020_W:If(Radio1.Selected.Value="No",false,true),maer:If(Radio2.Selected.Value="No",false,true),Location:Office365Users.MyProfileV2().officeLocation,pbsi:User().Email,Employee_x0020_Name:User().FullName,xcli:"Checked In",o5kf:Now()});Navigate('Check In Success',ScreenTransition.Cover)

Hi @Taylor28 ,

Within the formula I provided above, I do not use CountRows function. The formula I provided is not same that you mentioned. Have you taken a try with the formula I provided above (without CountRows() function)?

 

Based on the If formula that you mentioned above, I think there is something wrong with it. Please consider modify it as below:

If(
    CountRows(Filter('Employee Check In/Out', DateDiff(Created,Now(),Days)=0))>0,  // Modify frmula here
    Notify("You can't check in more than once per day",NotificationType.Error,1000),
    Patch(
          'Employee Check In/Out',
          Defaults('Employee Check In/Out'),
          {
            Title: "Check In",
            I_x0020_am_x0020_Feeling_x0020_W: If(Radio1.Selected.Value="No",false,true),
            maer: If(Radio2.Selected.Value="No",false,true),
            Location: Office365Users.MyProfileV2().officeLocation,
            pbsi:User().Email,
            Employee_x0020_Name: User().FullName,
            xcli: "Checked In",
            o5kf:Now()
          }
    );Navigate('Check In Success',ScreenTransition.Cover)
)     // do not miss close ')' here

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

 

In addition, please also take a try with the solution I provided above, check if it could help in your scenario.

 

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.

Hi!,

I tried both solutions you have provided and they worked great!.It accomplished what I was trying to do. The only warning I received was about delegation of large data sets which I believe is to be expected. Thanks Alot!

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (5,870)