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

This is creating a log, how do I get it to update instead?

When I run the following formula, it creates a log in my sharepoint list of all the interactions with my app:

Patch(EmployeeStatusLog,Defaults(EmployeeStatusLog),{Title:Label7.Text},{SignOut:'SignIn/SignOut'.FalseText},{Comments:TextInput1.Text},{ReturnDateTime:DatePicker1.SelectedDate},{Time:HourDropdown.Selected.Value&MinuteDropdown.Selected.Value},{Reason:Dropdown1.SelectedText});Reset(TextInput1);Reset(DatePicker1);Reset(Dropdown1);Reset(HourDropdown);Reset(MinuteDropdown);Navigate('Complete 1')

 

I want to create a second list 'EmployeeStatusLog2' that keeps the same line for each person and just updates as they interact with the app. 

Can anyone help me?

12 REPLIES 12
Highlighted
Super User
Super User

Re: This is creating a log, how do I get it to update instead?

@Alexyoung 

I dont see an employee name field in your Patch statement.  For simplicity's sake lets use the employee email in this example.  Its a good way to do things because its always unique

Put this code in the OnStart property of your app

 

// creates a new record if the employee has not logged into the app before
If(
    IsBlank(LookUp(EmployeeStatusLog2,Email=User().Email)),
    Patch(EmployeeStatusLog2, Defaults(EmployeeStatusLog2), {Email: User().Email})
)

// gets the Row ID for the employee
Set(employeeRowID, LookUp(EmployeeStatusLog2,Email=User().Email, ID))

 

When you want to update the record patch it like this (I only changed the 2nd argument).

 

Patch(EmployeeStatusLog, ID=employeeRowID,{Title:Label7.Text},{SignOut:'SignIn/SignOut'.FalseText},{Comments:TextInput1.Text},{ReturnDateTime:DatePicker1.SelectedDate},{Time:HourDropdown.Selected.Value&MinuteDropdown.Selected.Value},{Reason:Dropdown1.SelectedText});Reset(TextInput1);Reset(DatePicker1);Reset(Dropdown1);Reset(HourDropdown);Reset(MinuteDropdown);Navigate('Complete 1')

 

---
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
Helper I
Helper I

Re: This is creating a log, how do I get it to update instead?

Thanks for the help! 

 

There won't be multiple people logging onto the app, it will always be logged into as the same. I use a label on the page to indicate who is signing in and out. 

 

Is there another way?

Highlighted
Super User
Super User

Re: This is creating a log, how do I get it to update instead?

@Alexyoung 

You can still use this code.  It doesn't matter how many people are using the app.  It still works.

 

Did you try the code yet?

 

---
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
Helper I
Helper I

Re: This is creating a log, how do I get it to update instead?

I am trying to use it.

In the first IF statement the patch isn't working. 

Highlighted
Super User
Super User

Re: This is creating a log, how do I get it to update instead?

@Alexyoung 

Any error message?

Highlighted
Helper I
Helper I

Re: This is creating a log, how do I get it to update instead?

Looks like something's not quite right with it

Highlighted
Super User
Super User

Re: This is creating a log, how do I get it to update instead?

@Alexyoung 

You'll need to retype that.  Some brackets are in the wrong places or are missing.  Look at my code above.

Highlighted
Helper I
Helper I

Re: This is creating a log, how do I get it to update instead?

Still not working 

Highlighted
Super User
Super User

Re: This is creating a log, how do I get it to update instead?

@Alexyoung 

The close bracket ) is missing after EmployeeDataLog2.

 

 

Helpful resources

Announcements
secondImage

New Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

Check this Out

Helpful information

Featuring samples like Return to the Workplace and Emergency Response Applications

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,856)