cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Bartek1
Helper II
Helper II

Attendance in the office

Hello,

 

I am developing an app that will have two buttons - Check In and Check Out. The data is connected with my sharepoint list called EmployeeOffice.

 

I used the following formulas:

Check in button:

Set(CurrentCheckedInRecord; Patch(EmployeeOffice; Defaults(EmployeeOffice);{Title:"Office";StaffFullName:User().FullName;StaffEmail:User().Email;CheckIn:Now()}));; Navigate(CheckIn;ScreenTransition.Fade)

 

Check Out button:

Refresh(EmployeeOffice);; If(!IsBlank(CurrentCheckedInRecord); Patch(EmployeeOffice;CurrentCheckedInRecord;{CheckOut:Now()}));; Navigate(CheckOut;ScreenTransition.Fade)

 

I would like to add the following functionalities:

- you cannot check in again if you didnt check out (the message that you are already checked in should appear)

- you cannot check out if you didnt check in (the message that your have not checked in should appear)

 

I use FullName of my employees and Email address. Employee will check in and out everyday.

Thank you in advance!

 

Best regards,

Bartek

1 ACCEPTED SOLUTION

Accepted Solutions

@Bartek1 

It’s probably a delegation warning.  You can still send me the error message.  I can translate the Polish to English.

 

My guess is User().Email is causing the delegation problem.  To solve it, put this code in the OnStart property of your app.  Then ‘Run App OnStart’.

 

Set(varUserEmail, User().Email)

 

Then replace any references to User().Email in your formulas with varUserEmail instead.

 

---
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."

 

 

View solution in original post

12 REPLIES 12
mdevaney
Super User
Super User

@Bartek1 

My thought is just to make the buttons disabled when they should not be pressed via the DisplayMode property.

 

Put this code in the DisplayMode property of your CheckIn button

 

If(
    IsBlank(LookUp(EmployeeOffice, StaffEmail=User().Email And CheckOut=Blank())),
    DisplayMode.Edit,
    DisplayMode.Disabled
)

 

 

Then put this code in the DisplayMode property of your CheckOut button.

 

If(
    !IsBlank(LookUp(EmployeeOffice, StaffEmail=User().Email And CheckOut=Blank())),
    DisplayMode.Edit,
    DisplayMode.Disabled
)

 

 

---
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."

@mdevaney 

 

It does not work, when I insert the formula, it shows a yellow triangle next to both buttons and the message that the expected value is enum. There is also info that the formula may not work with the bigger data in 3 cases.

 

Maybe there should be something more?

@Bartek1 

I missed an important chunk of code because I was too focused on writing the logical condition.  Please see my original post for the corrected code.

 

---
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."

@mdevaney 

 

Now it shows that there is a wrong number of arguments: Received 3, Expected 1.

 

 

@Bartek1 

Can you please supply a screenshot of the formula you wrote and the error message along side it?

 

@mdevaney 

 

My PowerApp is in Polish so it will be hard to understand, but I am using the same formula as you. In the Formula icon it shows two errors:

1. Incorrect number of arguments: received: 3, expected 1. 

Location Button1

.Displaymode

 

2. Incorrect number of arguments: received: 1, expected at least 2. 

Location Button1

.Displaymode

 

And then there are three in the warning section regading the number of records.

 

The app is functioning, but the button has still this yellow triangle.

Do you know why it might be like this? Maybe something is missing in the lookup or isblank formula?

 

 

@Bartek1 

I missed some brackets.  Corrected above again.  Sorry, I'm typing mostly from a mobile phone.

 

You can send screenshots in Polish.   Doesn't matter to me.  I see all type of languages here.  PowerApps is a common language though.

 

---
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."

@mdevaney 

 

Now the erros dissapeared but there are still 6 warnings.

 

Attached my formulas and how it looks. Still got triangles, and now the check in button is all the time in "disabled" mode, as I cannot click it. The sherpoint list is empty. Please ba aware that in my PowerApp comma is ";".

 

Thank you for your support!!

 

 
 

@Bartek1 

It’s probably a delegation warning.  You can still send me the error message.  I can translate the Polish to English.

 

My guess is User().Email is causing the delegation problem.  To solve it, put this code in the OnStart property of your app.  Then ‘Run App OnStart’.

 

Set(varUserEmail, User().Email)

 

Then replace any references to User().Email in your formulas with varUserEmail instead.

 

---
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."

 

 

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Difinity Conference 2022

Difinity Conference 2022

Register today for two amazing days of learning, featuring intensive learning sessions across multiple tracks, led by engaging and dynamic experts.

European SharePoint Conference

European SharePoint Conference

The European SharePoint Conference returns live and in-person November 28-December 1 with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

Power Apps Ideas

Changes to Ideas Coming

We are excited to announce a new way to share your ideas for Power Apps!

Top Solution Authors
Top Kudoed Authors
Users online (2,131)