cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
AaronTheYoung
Helper III
Helper III

Updating a Sharepoint List

Just learning Powerapps and I am running into an update record problem.  I've not figured out how to to do this yet.

 

I have created a simple check in app and all it tracks is Username, TimeIn, TimeOut, INOUTStatus

 

When I use Patch to add a record to the Sharepoint list when the user checks-in by pressing the Check-In Button, it does exactly what I expect it to.  It creates a new record with Username, TimeIn, and INOUTStatus.   There is no check out time since they have not checked out yet.

 

Patch('OfficeCheck-DATA', {Title: User().FullName, TimeIN: Now(), InOUTStatus: true}); Navigate(CheckedINScreen, ScreenTransition.None);

When I have them select the CheckOut button, it creates a *NEW* record with Username, TimeOUT and INOUTStatus. 

 

Patch('OfficeCheck-DATA', {Title: User().FullName, TimeOut: Now(), InOUTStatus: true}); Navigate(CheckedINScreen, ScreenTransition.None);

 

How do I designate that I want to use the entry that was created with CheckIn?

2 ACCEPTED SOLUTIONS

Accepted Solutions

Hi @AaronTheYoung ,

 

the issue is with = sign, use this:

Patch('OfficeCheckINOUT-DATA', LookUp('OfficeCheckINOUT-DATA', Title=varUser.FullName), {Title: varUser.FullName, DateTimeOUT: Now(), CheckedInStatus:false});

 
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,
Krishna
If this post helps you 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 and if it solved your issue consider Accept it as the solution to help the other members / new members of the community.

View solution in original post

@AaronTheYoung ,

 

use this:

Patch('OfficeCheckINOUT-DATA', Lookup(Sort('OfficeCheck-DATA',ID,Descending),Title=varUser.FullName), {Title: varUser.FullName, DateTimeOUT: Now(), CheckedInStatus:false});

 
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,
Krishna
If this post helps you 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 and if it solved your issue consider Accept it as the solution to help the other members / new members of the community.

View solution in original post

33 REPLIES 33
Drrickryp
Super User
Super User

Hi @AaronTheYoung 

Patch requires three elements, the datasource being used, the record being patched and the fields of the record that are being patched.  If you are adding a new record, the second element is usually specified as Defaults() meaning that it uses the defaults of a blank record to patch the fields specified within the curly braces.  Your formula didn't specify Defaults so I'm not sure why it worked!  The correct syntax for creating a new record for your datasource would be.

 

Patch('OfficeCheck-DATA',Defaults('OfficeCheck-DATA'), {Title: User().FullName, TimeIN: Now(), InOUTStatus: true})

 

To patch an existing record, you would need to specify the record using a Lookup() to the datasource like in the following formula.  

 

Patch('OfficeCheck-DATA',Lookup('OfficeCheck-DATA',ID=Gallery1.Selected.ID), {Title: User().FullName, TimeIN: Now(), InOUTStatus: true})

for more information regarding the Patch function see the documentation https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-patch  or review Shane Young's video on the Patch function on a SharePoint list. https://www.youtube.com/watch?v=gX5q_V3U8-s 

 

KrishnaV
Community Champion
Community Champion

Hi @AaronTheYoung ,

 

I agree with @Drrickryp if you implement with the gallery if it is with a button click "Check-Out" on the app level try the below:

Patch('OfficeCheck-DATA',ID=(LookUp(OfficeCheck-DATA,'Created By'.Email = User().Email And IsBlnak(TimeOut)).ID, {Title: User().FullName, TimeIN: Now(), InOUTStatus: true}); 
Navigate(CheckedINScreen, ScreenTransition.None);

 
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,
Krishna
If this post helps you 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 and if it solved your issue consider Accept it as the solution to help the other members / new members of the community.

Thanks for your response. Your solution won't work because I never put any of the data into a Gallery.

 

My user checks in, it tells them they are checked-in, and then the only thing they can do is check out or quit the app.  They can't see any logging that is occurring from these two actions.  It's a VERY simple tool for the user.

 

So how I do I reference this new record if it is not in a gallery?.  

 

It should be the only record in the sharepoint list that has a blank checkout column.  does that help?  I was thinking I could somehow do a look up on that, but I'm not sure of the command syntax.

@AaronTheYoung 

You would lookup the last record that user created as follows 

 

Patch('OfficeCheck-DATA',Lookup(Sort('OfficeCheck-DATA',ID,Descending),Title=User().FullName), {Title: User().FullName, TimeIN: Now(), InOUTStatus: true})

 

You would need to change the fields to specify timeOUT instead of timeIN. 

 

I will try this Krishna.

Thanks for the code, but it still isn't working. Although it seems syntactically correct, I'm getting a delegation warning.  

 

AaronTheYoung_0-1595639240096.png

 

I only have about 30 records in my Sharepoint List.

 

Hi @AaronTheYoung ,

 

Just test the functionality and then let me know I can help you with the delegation issue.


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,
Krishna
If this post helps you 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 and if it solved your issue consider Accept it as the solution to help the other members / new members of the community.

It doesn't not seem to want to execute.  Normally, my button would navigate back to the opening screen

 

Patch('OfficeCheckINOUT-DATA', ID=LookUp(Sort('OfficeCheckINOUT-DATA', ID,Descending), Title=User().FullName), {Title: User().FullName, DateTimeOUT: Now(), CheckedInStatus=false)); Navigate(CheckINOUTScreen, Transition.None);

Hi @AaronTheYoung ,

 

try as below:

on AppStart:
Set(varUser,User())

on button click:
Patch('OfficeCheckINOUT-DATA', ID=LookUp('OfficeCheckINOUT-DATA', Title=varUser.FullName).ID, {Title: varUser.FullName, DateTimeOUT: Now(), CheckedInStatus=false));

 
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,
Krishna
If this post helps you 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 and if it solved your issue consider Accept it as the solution to help the other members / new members of the community.

Helpful resources

Announcements
Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on August 17, 2022 at 8am PDT.

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

365 EduCon 768x460.png

Microsoft 365 EduCon

Join us for two optional days of workshops and a 3-day conference, you can choose from over 130 sessions in multiple tracks and 25 workshops.

Users online (7,109)