cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Frequent Visitor

Staff attendance/monitoring

Hi all,

 

I'm currently trying to make a staff attendance app using a SharePoint list. The app would be used on a tablet in our reception area. The staff member would select their name from a drop down then click the sign in button. I have achieved this with:

 

Patch(StaffAttendanceTest,Defaults(StaffAttendanceTest), {Title: "Attendance"}, {SignIn: Now()}, {StaffName: Dropdown1.Selected} )

This works as intended. 

 

I am now struggling with the signing out part. Ideally, we would want a staff member to choose their name from the dropdown, press the sign out button, and it will add that information onto the same list item that the sign in button created for that staff member. 

 

I tried to adapt a solution from a similar issue:

 

Refresh(StaffAttendanceTest);
If(
    !IsBlank(LookUp(StaffAttendanceTest,StaffName=Dropdown1.Selected && Text(Created,"[$-en-US]mm/dd/yyyy")=Text(Now(),"[$-en-US]mm/dd/yyyy"))),
    Patch(
      StaffAttendanceTest,
       LookUp(StaffAttendanceTest,StaffName=Dropdown1.Selected && Text(Created,"[$-en-US]mm/dd/yyyy")=Text(Now(),"[$-en-US]mm/dd/yyyy")),
       {
        SignOut: Now()
       }
     )
)

But I get an invalid argument type on the = part of StaffName=Dropdown1.Selected.

 

Any help would be greatly appreciated!

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super User
Super User

Re: Staff attendance/monitoring

What type of SP column is StaffName? If it’s a text column changing Dropdown1.Selected to Dropdown1.Selected.Value would work. If it’s a Person/Group field you’d need to do something more complicated... let me know

FYI, for Person/Group it would be similar to this...
https://powerusers.microsoft.com/t5/Building-PowerApps-Formerly/Saving-data-from-powerapps-to-SP-lis...

View solution in original post

8 REPLIES 8
Highlighted
Super User
Super User

Re: Staff attendance/monitoring

What type of SP column is StaffName? If it’s a text column changing Dropdown1.Selected to Dropdown1.Selected.Value would work. If it’s a Person/Group field you’d need to do something more complicated... let me know

FYI, for Person/Group it would be similar to this...
https://powerusers.microsoft.com/t5/Building-PowerApps-Formerly/Saving-data-from-powerapps-to-SP-lis...

View solution in original post

Highlighted
Frequent Visitor

Re: Staff attendance/monitoring

Thanks for the reply!

It was a choice column (with the staff names as choices) but I changed it to a text column, and did as you said with the .value.

 

There seems to be an issue with this. The sign out button now works, I can select Name 1, 2 or 3 and click the sign out button. However, if a person then signs in again - which creates a new item (which I want to happen) and then clicks the sign out button, it will update the first item created in their name, rather than the new item.

 

(As shown below, Name 1 signed in/out fine, then Name 1 signed in again, but when the sign out button was pressed, it updated the first item)Screen Shot 2019-10-26 at 18.11.42.png

 

Highlighted
Super User
Super User

Re: Staff attendance/monitoring

@AB4N 

I think that the 1st record is always updating on signout because your LookUp criteria asks to match the first record with the same sign in date.

 

 LookUp(StaffAttendanceTest,StaffName=Dropdown1.Selected && Text(Created,"[$-en-US]mm/dd/yyyy")=Text(Now(),"[$-en-US]mm/dd/yyyy"))

 

My suggestion would be to do a LookUp for the 1st matching record that has blank SignOut date instead.  Normally date columns are non-delegable but the exception is for checking Blank values.  Perhaps you have a good reason for Filtering on the Created date.  If so, please share it.  However, my method will ensure there are no sign-ins without a sign-out.

 

LookUp(StaffAttendanceTest,StaffName=Dropdown1.Selected && IsBlank(SignOut))

Let me know if this works Cat Happy

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

Highlighted
Frequent Visitor

Re: Staff attendance/monitoring

Thank you so much for your help!

 

I am having one slight issue with this. As shown below, if Name 2 doesn't sign out on one day, and the next day signs in and then signs out - the 'sign out' time will be entered in the previous blank item for Name 2 and not the current. 

 

Screen Shot 2019-10-26 at 23.39.03.png

 

Is there a possible solution to this? 

 

Thanks again!

 

Highlighted
Super User
Super User

Re: Staff attendance/monitoring

To get your desired result we would just put some of your previous code back in the LookUp. I left this out intentionally because I thought you would always want a punch out for every punch in (plus it works properly for overnight shifts). However, your requirements appear to be different than I had anticipated. Sorry.

LookUp(StaffAttendanceTest,StaffName=Dropdown1.Selected, IsBlank(SignOut), Text(Created,"[$-en-US]mm/dd/yyyy")=Text(Now(),"[$-en-US]mm/dd/yyyy"))


Please Accept as Solution if this post answered your question so others may find it more quickly. If you found this post helpful consider giving it a Thumbs Up.
Highlighted
Frequent Visitor

Re: Staff attendance/monitoring

I've added that bit back in now (added the .value as I changed the StaffName to text rather than choices):

Refresh(StaffAttendanceTest);
If(
    !IsBlank(LookUp(StaffAttendanceTest,StaffName=Dropdown1.Selected.Value && IsBlank(SignOut),Text(Created,"[$-en-US]mm/dd/yyyy")=Text(Now(),"[$-en-US]mm/dd/yyyy"))),
    Patch(
      StaffAttendanceTest,
       LookUp(StaffAttendanceTest,StaffName=Dropdown1.Selected.Value && IsBlank(SignOut),Text(Created,"[$-en-US]mm/dd/yyyy")=Text(Now(),"[$-en-US]mm/dd/yyyy")),
       {
        SignOut: Now()
       }
     )
)

But now I'm getting quite a few errors, can you see anything obvious I've missed out?

 

Thank you!

Highlighted
Super User
Super User

Re: Staff attendance/monitoring

@AB4N 

Looks like I put a comma ( , ) where and AND operator ( && ) should have been in the LookUp.  Please make these 2 corrections highlighted in blue.

 

Refresh(StaffAttendanceTest);
If(
    !IsBlank(LookUp(StaffAttendanceTest,StaffName=Dropdown1.Selected.Value && IsBlank(SignOut) && Text(Created,"[$-en-US]mm/dd/yyyy")=Text(Now(),"[$-en-US]mm/dd/yyyy"))),
    Patch(
      StaffAttendanceTest,
       LookUp(StaffAttendanceTest,StaffName=Dropdown1.Selected.Value && IsBlank(SignOut) && Text(Created,"[$-en-US]mm/dd/yyyy")=Text(Now(),"[$-en-US]mm/dd/yyyy")),
       {
        SignOut: Now()
       }
     )
)

 

I was responding to you via mobile phone the whole time yesterday so it was very hard to review my syntax.  Sorry.  If you are still getting errors after this please send a screenshot.

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

Highlighted
Frequent Visitor

Re: Staff attendance/monitoring

Noticed that this morning! Thank you so much for all of your help! everything is running smoothly now!

Helpful resources

Announcements
secondImage

Demo-Extravaganza 2020

Check out these cool Power Apps & vote on your favorite!

secondImage

Community Highlights

Check out whats happening in Power Apps

secondImage

Community User Group Member Badges

FIll out a quick form to claim your community user group member badge today!

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (8,396)