cancel
Showing results for 
Search instead for 
Did you mean: 
Reply

Employee signin/out

  • have a list called 'StaffWhosin' the 'employee' name is a lookup list from 'StaffNames' i can get a signin date time etc, but the signout againist the name, doesnt work, can you help again.

 

basixally on the sign out , I would like a dropdown which it gets from the ‘staffwhosin’ list of staff that have already signed in - then pick the name from the dropdown on the ‘sign out’ screen , they would then press ‘sign out’ button , function would then find the record in the ‘staffwhosin’ then put a date and time in the ‘sign out’ column next to the name selected from the dropdown.

can anyone help plesse with code 

1 ACCEPTED SOLUTION

Accepted Solutions
poweractivate
Most Valuable Professional
Most Valuable Professional

@AndyPowerAppNew 

 

I try once more to help you, I just built out the whole app myself and it works for your scenario on my side.

I have a sign in and out functionality which also knows if the person is currently signed in or out, and it works properly when multiple people are using the app at the same time.

 

I corrected any imperfection in the previous formulas for you, so please follow the below including the screenshots, step by step, and it should work for you.

 

These are steps to build everything from the List to the whole app.

These steps are different from what I gave before and the formulas are different,

so be sure to follow each step carefully below.

 

1. Here is how your SharePoint List should look and it should be called MyStaffList.

Go ahead and see the next steps to check the setting for each column.

Step1.png

 

Title should just be left alone and it should still be called Title for now.

2. Here are the settings for the other columns

2a. SignInDateTime

 Site2.png

 

2b. SignOutDateTime

Site3.png

 

2c. SignedIn

Site1.png

Make sure the Default value is set to No for the SignedIn column just like in the above screenshot.

 

Now to build the app:

 

3. After doing both steps above you have built out the SharePoint List MyStaffList 

Add this SharePoint List MyStaffList  as data source to a brand new canvas app

 

When you are done adding the data source it should look like this:

poweractivate_0-1671661081646.png

 

For the next steps from this point, just ignore any errors (if any even appear at all), and do all of the steps all the way through, and there should be no more errors by the time you are done with all the steps below.

 

4. Now add a few Screens - rename the first one SignInScreen and the next one MainScreen - and the third one BlankScreen

 

4b. OnVisible of SignInScreen use this formula

 

Set(var_myEmpName,User().Email)

 

Step2.png

4c. For best results, now click on BlankScreen from the left side (tree view) and then click on SignInScreen again. This initializes the variable, so you may see results more quickly in the next steps even as you are doing the steps.

 

5. Now add a Label control and call it SigninStatusLabel1.

For the Text property put this formula:

 

"Signed In: " & With({_myRecord:LookUp(MyStaffList,Title=var_myEmpName)},If(IsBlank(_myRecord),false,_myRecord.SignedIn))

 

Step3.png

6. Add another Label Control. Below it's called Label2. I've left the name of the Control alone this time. You can rename it if you want to.

For the text Property of that Label put

 

var_myEmpName

 

Step4.png

7. Add a Button. Below it's called Button1. I've left the name of the Control alone this time. You can rename it if you want to.

For the OnSelect of that Button use this formula:

 

With
(
	 {_myRecord:LookUp(MyStaffList,Title=var_myEmpName)}
	,If
	 (
	 	!IsBlank(_myRecord)
	 	,If
	 	(
	 		_myRecord.SignedIn
	 	   ,Notify(_myRecord.Name & " is already signed in - they must sign out first",Error);
	 		Navigate(MainScreen)
	 	   ,Patch //change the existing record to signed in
	 	   (
	 		  MyStaffList
	 		 ,{
	 			  ID: _myRecord.ID
	 			 ,SignedIn: true
	 			 ,SignInDateTime: Now()
	 		  }
	 	   );Notify(var_myEmpName & " has signed in!",Success);Navigate(MainScreen)
	 	)
	 	,Patch //create new record if not existing yet and set it to signed in
	 	 (
	 		MyStaffList
	 	   ,{
	 			Title:var_myEmpName
	 		   ,SignedIn: true
	 		   ,SignInDateTime: Now()
	 		}
	 	 );Notify(var_myEmpName & " has signed in for the first time!",Success);Navigate(MainScreen)
	 )
)
	 

 

Step5.png

7b. For the Text property of that Button put

 

"Sign In"

 

poweractivate_1-1671661677881.png

8. Now go to MainScreen

Add a Label Control. I have left the name as the default, you can rename it if you want to.

For the Text property put:

 

var_myEmpName

 

Step6.png

9. Now add a Label control and call it SigninStatusLabel2.

For the Text property put this formula:

 

"Signed In: " & With({_myRecord:LookUp(MyStaffList,Title=var_myEmpName)},If(IsBlank(_myRecord),false,_myRecord.SignedIn))

 

Step7.png

10. Now add a Button control 

For the OnSelect property put this formula:

 

With
(
	 {_myRecord:LookUp(MyStaffList,Title=var_myEmpName)}
	,If
	(
		!IsBlank(_myRecord)
		,If
		(
		   !_myRecord.SignedIn
		   ,Notify(_myRecord.Name & " is already signed out - they must sign in first",Error);
			Navigate(SignInScreen)
		   ,Patch //change the existing record to not signed in
		   (
			  MyStaffList
			 ,{
				  ID: _myRecord.ID
				 ,SignedIn: false
				 ,SignOutDateTime: Now()
			  }
		   );Notify(var_myEmpName & " has signed out!",Success);Navigate(SignInScreen)
		)
		,Notify(var_myEmpName & " does not exist in the table / is not signed in",Error);
		 Navigate(SignInScreen)
		
	)
)

 

Step8.png

 10b.  For the Text property of that Button put

 

"Sign Out"

 

poweractivate_2-1671661767336.png

11. Now try the app. If not sure how to try it, check Step 12 below.

The app should know if they are currently signed in or not.

Even if you test the app starting with the MainScreen instead of starting with the SignInScreen it should still work correctly and it knows if they are not signed in, and takes them to the Sign In page, giving a message that they were not yet signed in.

 

Same is true vice versa - if they are already Signed In, and you intentionally start the app while on the SignInScreen and press Sign In, it should not sign them in again, it should take them to the MainScreen instead, giving a message that they were already signed in.

 

If you want step by step on how to try it, see the next step.

 

12. Preview the App (or you can ALT+CLICK if you want to test directly in the Editor)

12a. Click on Sign In.
After you see the green message saying they successfully signed in, go to your SharePoint List and manually check the entry. You should see it as correct - the Sign In Date Time

 

12b. Click on Sign Out
After you see the green message saying they successfully signed out, go to your SharePoint List and manually check the entry. You should see it as correct - the Sign Out Date Time

 

13. Repeat Steps 12a and 12b  above again.

Notice it's working and it updates the Sign In Date Time, Sign Out Date Time and Sign In Status accordingly to the correct record in the SharePoint List every time.

 

If you use multiple different users at the same time on this app, it should work correctly for all of them.

 

14. If you like this solution, go ahead and add in your other columns you had before into this same SharePoint List MyStaffList

 

See if it helps @AndyPowerAppNew 

 

P.S.:

 

@AndyPowerAppNew 

 

have attached a working sample msapp file SignInOutApp_1.msapp of the full app built out with all formulas. 

if you would like to import a full, working example yourself for your convenience.

 

To use the sample msapp attached, follow these steps:

 

1) Download the msapp file attached to this post (it's at the bottom of this post), to Desktop or a folder of your choice, by clicking on it from this post.

 

2) Create a new, blank Power App Canvas App

 

3) Click on the three dotsellipses (just to the right of Settings)-> then from the menu that appears, click Open

poweractivate_0-1667393291182.png

 

4) Click Browse

poweractivate_1-1667393328619.png

5 ) Navigate to location of .msapp file from Step 1, select it, and press the "Open" button.

6 ) The working example msapp file should load

 

7) There will be errors showing up. So now you need to add the data source MyStaffList.

Follow the instructions at the top of this post to build out the SharePoint List from scratch.

 

See if this helps as well @AndyPowerAppNew 

 

 

View solution in original post

53 REPLIES 53
poweractivate
Most Valuable Professional
Most Valuable Professional

@AndyPowerAppNew To make this easier you may want to have a Yes/No column in your SharePoint List called SignedIn or something like that.

 

Dropdown Items

 

Distinct(Filter(StaffWhosIn,SignedIn = true), EmployeeName)
//Replace EmployeeName with whatever column(s) is the name of your empoyee

 

OnSelect of Sign out button

 

Patch
(
    StaffWhosIn
   ,Filter(StaffWhosIn, EmployeeName = YourDropdownName.Selected.Result && SignedIn = true)
   ,{
      SignedIn = false, 
      //YourSignOutTimeField=YourSignOutTime...
      //..and so forth
    }
)

 

 

In the above solution, I take into account that there may be more than one Record in your StaffWhosIn List, that is actually the same person. I am not sure how you are doing it, but I believe you might be using "StaffWhosIn" to populate who is signing in. While populating this List, it is possible that the same person might appear in this list more than once.  It may not be ideal to do it that way, because it may be better if this StaffWhosIn list only contained the employee name, sign in status, last sign in date/time and last sign out date/time. For a full list of signed in dates and times, I think there should be a separate List being used (if it's even needed) for the full audit log of sign in and out dates/times . The way you have it, it's possible that StaffWhosIn List is being used both to determine the current sign in status and store the full audit log of signed in dates and times, and using the same List for both purposes is something I do not recommend as too ideal - however, if you test it and the solution is somewhat acceptable for you, then you can go it with it for now if you really want. 

 

Hi @poweractivate , I’m not sure I understand - here is what I would like to do , 

Hello, Thank you for the reply, here are are screen shots attached, for the employee signout, its a lookup, so the staff can choose their name, and press 'signout' button, then it will update the record on the SharePoint list with the information in the correct column, so there would be only one entry instead of 2 records which i have at the moment. so for the vististor signout, it would a little different using a text box where they type their name then press signout, then the record would be updated. i would like the single record updated, so i have one record only.

Thank you so much, is there a way on sign out they can only see their name, or type their name then ‘sign out’ so they cannot sign out another user ?

Hope it makes sense

I have a screenshot of my staff sign app form , the employee name , is taken from ‘staffwhosIn’ list, so only staff that have signed will appear here.

 

then they type their name, press sign out, this will update column in ‘staffwhosin’ list with signoutDateTime, against the record that is already there, so you can only sign out staff That have signed in to begin with 

does that make sense ?

Just thought if staff wanted to have an option to sign out for lunch , then sign back in, can they do this , I put two extra columns in the ‘staffwhosin’ list called ‘lunchIn’ and the column ‘lunchOut, how would that work ?

poweractivate
Most Valuable Professional
Most Valuable Professional

@AndyPowerAppNew 
You can use User().FullName to get the current name of the user. 

If you only want to know the last signed in and out time, then using StaffWhosIn should suffice, and making sure there's only one record in there. However, you need to know if they are signed in or not, so a Yes/No column SignedIn may help you here.

 

You can try something like this OnSelect of the Sign Out button :

 

With
(
    {_myRecord:LookUp
               (
                   StaffWhosIn
                   ,'Employee Name' = User().FullName && SignedIn = true
                )
    }
   ,If
    (
        !IsBlank
        (
           _myRecord
          ,Patch
           (
               StaffWhosIn
              ,{
                   ID: _myRecord.ID
                  ,SignedIn: false
                  ,SignOutTimeDate: Now()
               }
           )
        )
    )
)

 

You may need to change your Sign in so it sets SignedIn = true when they sign in, for the above to work.

 

See if it helps @AndyPowerAppNew 

Hi @poweractivate , I will try this code the sign out button instead of what I have there now, will this code update the ‘sign outTimeDate’ column on the same record in the SP list ? So it will only sing out user if the staff name exists in the SP list ? Is that right ?

Hi , I already have a column shows the user had singed in , will your code check that column ? Please see attached 

Hello @poweractivate , just wondering if there is an update for me please ?

poweractivate
Most Valuable Professional
Most Valuable Professional

@AndyPowerAppNew 

 

So it will only sing out user if the staff name exists in the SP list ? Is that right ?

Yes my recent formula I gave that has the With function used in it, only signs out that specific person who is signed in, but you should have an additional Yes/No column called SignedIn for it to work. You should require the value, and put the default value to No if prompted on creation of this SharePoint column, to default to them not being signed in.

 

 


@AndyPowerAppNew wrote:
  • I already have a column shows the user had singed in , will your code check that column ?

 


No that is the sign out date/time and you also have sign/in date time. Simply checking the presence of these columns is not a good idea. If you want to sign in or out again, how do you know they're signed in or out if they have already signed in and out once before? If you have already signed in and signed out before, you will have a date and time in both columns. Does that mean you're signed in, or signed out? It's ambiguous. So that's why you should have the additional SignedIn column with Yes/No choice to make it very clear.

 

You should change your Sign in button code to set them as signed in as well by setting the SignedIn to true upon sign in, like this:

 

With
(
    {_myRecord:LookUp
               (
                   StaffWhosIn
                   ,'Employee Name' = User().FullName
                )
    }
   ,If
    (
        !IsBlank
        (
           _myRecord
          ,If
           (
               _myRecord.SignedIn
               ,Notify(_myRecord.'Employee Name' & " is already signed in",Error)
               ,Patch
               (
                  StaffWhosIn
                 ,{
                      ID: _myRecord.ID
                     ,SignedIn: true
                     ,SignInTimeDate: Now()
                  }
              )
           )
          ,Patch
           (
               StaffWhosIn
              ,{
                   'Employee Name' = User().FullName
                  ,SignedIn: true
                  ,SignInTimeDate: Now()
               }
           )
        )
    )
)

 

This formula only signs them in, if they are signed out. There is a difference though - if they really don't exist in this list yet, a new record is created for them. If they are already signed in, an error notification is displayed.

 

Similarly, for the formula I gave, it signs them out only if signed in. If you want to add a notification error if not signed in, do this for sign out:

 

With
(
    {_myRecord:LookUp
               (
                   StaffWhosIn
                   ,'Employee Name' = User().FullName
                )
    }
   ,If
    (
        !IsBlank
        (
           _myRecord
          ,If
           (
               !_myRecord.SignedIn
               ,Notify(_myRecord.'Employee Name' & " is already signed out",Error)
               ,Patch
               (
                  StaffWhosIn
                 ,{
                      ID: _myRecord.ID
                     ,SignedIn: false
                     ,SignOutTimeDate: Now()
                  }
              )
           )
          ,Notify(_myRecord.'Employee Name' & " is signed out because they have never signed in",Error)
        )
    )
)

 

See if it helps @AndyPowerAppNew 

Helpful resources

Announcements

Community will be READ ONLY July 16th, 5p PDT -July 22nd

Dear Community Members,   We'd like to let you know of an upcoming change to the community platform: starting July 16th, the platform will transition to a READ ONLY mode until July 22nd.   During this period, members will not be able to Kudo, Comment, or Reply to any posts.   On July 22nd, please be on the lookout for a message sent to the email address registered on your community profile. This email is crucial as it will contain your unique code and link to register for the new platform encompassing all of the communities.   What to Expect in the New Community: A more unified experience where all products, including Power Apps, Power Automate, Copilot Studio, and Power Pages, will be accessible from one community.Community Blogs that you can syndicate and link to for automatic updates. We appreciate your understanding and cooperation during this transition. Stay tuned for the exciting new features and a seamless community experience ahead!

Summer of Solutions | Week 4 Results | Winners will be posted on July 24th

We are excited to announce the Summer of Solutions Challenge!   This challenge is kicking off on Monday, June 17th and will run for (4) weeks.  The challenge is open to all Power Platform (Power Apps, Power Automate, Copilot Studio & Power Pages) community members. We invite you to participate in a quest to provide solutions in the Forums to as many questions as you can. Answers can be provided in all the communities.    Entry Period: This Challenge will consist of four weekly Entry Periods as follows (each an “Entry Period”)   - 12:00 a.m. PT on June 17, 2024 – 11:59 p.m. PT on June 23, 2024 - 12:00 a.m. PT on June 24, 2024 – 11:59 p.m. PT on June 30, 2024 - 12:00 a.m. PT on July 1, 2024 – 11:59 p.m. PT on July 7, 2024 - 12:00 a.m. PT on July 8, 2024 – 11:59 p.m. PT on July 14, 2024   Entries will be eligible for the Entry Period in which they are received and will not carryover to subsequent weekly entry periods.  You must enter into each weekly Entry Period separately.   How to Enter: We invite you to participate in a quest to provide "Accepted Solutions" to as many questions as you can. Answers can be provided in all the communities. Users must provide a solution which can be an “Accepted Solution” in the Forums in all of the communities and there are no limits to the number of “Accepted Solutions” that a member can provide for entries in this challenge, but each entry must be substantially unique and different.    Winner Selection and Prizes: At the end of each week, we will list the top ten (10) Community users which will consist of: 5 Community Members & 5 Super Users and they will advance to the final drawing. We will post each week in the News & Announcements the top 10 Solution providers.  At the end of the challenge, we will add all of the top 10 weekly names and enter them into a random drawing.  Then we will randomly select ten (10) winners (5 Community Members & 5 Super Users) from among all eligible entrants received across all weekly Entry Periods to receive the prize listed below. If a winner declines, we will draw again at random for the next winner.  A user will only be able to win once overall. If they are drawn multiple times, another user will be drawn at random.  Individuals will be contacted before the announcement with the opportunity to claim or deny the prize.  Once all of the winners have been notified, we will post in the News & Announcements of each community with the list of winners.   Each winner will receive one (1) Pass to the Power Platform Conference in Las Vegas, Sep. 18-20, 2024 ($1800 value). NOTE: Prize is for conference attendance only and any other costs such as airfare, lodging, transportation, and food are the sole responsibility of the winner. Tickets are not transferable to any other party or to next year’s event.   ** PLEASE SEE THE ATTACHED RULES for this CHALLENGE**   Week 1 Results: Congratulations to the Week 1 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Community MembersNumber of SolutionsSuper UsersNumber of Solutions @anandm08  23 @WarrenBelz  31 @DBO_DV  10 @Amik  19 AmínAA 6 @mmbr1606  12 @rzuber  4 @happyume  7 @Giraldoj  3@ANB 6 (tie)   @SpongYe  6 (tie)     Week 2 Results: Congratulations to the Week 2 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Community MembersSolutionsSuper UsersSolutions @anandm08  10@WarrenBelz 25 @DBO_DV  6@mmbr1606 14 @AmínAA 4 @Amik  12 @royg  3 @ANB  10 @AllanDeCastro  2 @SunilPashikanti  5 @Michaelfp  2 @FLMike  5 @eduardo_izzo  2   Meekou 2   @rzuber  2   @Velegandla  2     @PowerPlatform-P  2   @Micaiah  2     Week 3 Results: Congratulations to the Week 3 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge.   Week 3:Community MembersSolutionsSuper UsersSolutionsPower Apps anandm0861WarrenBelz86DBO_DV25Amik66Michaelfp13mmbr160647Giraldoj13FLMike31AmínAA13SpongYe27     Week 4 Results: Congratulations to the Week 4 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge.   Week 4:Community MembersSolutionsSuper UsersSolutionsPower Apps DBO-DV21WarranBelz26Giraldoj7mmbr160618Muzammmil_0695067Amik14samfawzi_acml6FLMike12tzuber6ANB8   SunilPashikanti8

Check Out | 2024 Release Wave 2 Plans for Microsoft Dynamics 365 and Microsoft Power Platform

On July 16, 2024, we published the 2024 release wave 2 plans for Microsoft Dynamics 365 and Microsoft Power Platform. These plans are a compilation of the new capabilities planned to be released between October 2024 to March 2025. This release introduces a wealth of new features designed to enhance customer understanding and improve overall user experience, showcasing our dedication to driving digital transformation for our customers and partners.    The upcoming wave is centered around utilizing advanced AI and Microsoft Copilot technologies to enhance user productivity and streamline operations across diverse business applications. These enhancements include intelligent automation, AI-powered insights, and immersive user experiences that are designed to break down barriers between data, insights, and individuals. Watch a summary of the release highlights.    Discover the latest features that empower organizations to operate more efficiently and adaptively. From AI-driven sales insights and customer service enhancements to predictive analytics in supply chain management and autonomous financial processes, the new capabilities enable businesses to proactively address challenges and capitalize on opportunities.    

Updates to Transitions in the Power Platform Communities

We're embarking on a journey to enhance your experience by transitioning to a new community platform. Our team has been diligently working to create a fresh community site, leveraging the very Dynamics 365 and Power Platform tools our community advocates for.  We started this journey with transitioning Copilot Studio forums and blogs in June. The move marks the beginning of a new chapter, and we're eager for you to be a part of it. The rest of the Power Platform product sites will be moving over this summer.   Stay tuned for more updates as we get closer to the launch. We can't wait to welcome you to our new community space, designed with you in mind. Let's connect, learn, and grow together.   Here's to new beginnings and endless possibilities!   If you have any questions, observations or concerns throughout this process please go to https://aka.ms/PPCommSupport.   To stay up to date on the latest details of this migration and other important Community updates subscribe to our News and Announcements forums: Copilot Studio, Power Apps, Power Automate, Power Pages

Users online (1,806)