cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
imaliasad
Level: Powered On

Update data with Patch and Lookup

Hi everyone,

 

This is very basic, but I'd like to ask how can I update the form data by using Patch and Lookup. Here's my code for inserting the data with a Patch function.  I'm an absolute beginner please bear with me. Thank you.

 

Patch(
    Table_SiteTimesheet,
    Defaults(Table_SiteTimesheet),
    {
        Work_Date: Value(Date_WorkDate_1.SelectedDate),
        Name_Project: DD_NameProject_1.Selected.Name_Project,
        Code_Project: DD_NameProject_1.Selected.Code_Project,
        Note: Text_Note_1.Text,
        Start: DD_StartTime_1.Selected.Value,
        End: DD_EndTime_1.Selected.Value,
        User_Name: User().Email,        
        ModifiedOn_Date: Today()
    }
);
1 ACCEPTED SOLUTION

Accepted Solutions
myke_deabreu
Level 8

Re: Update data with Patch and Lookup

I think I understand what you asking.

 

First assign the ID you want to update to a varible (e.g. Set(varname, the id you updating) 

 

Then you could do something like this:

 

Patch(
Table_SiteTimesheet,
First(Filter(Table_SiteTimesheet,ID_Timesheet=varname)),
{
Work_Date: Value(Date_WorkDate_1.SelectedDate),
Name_Project: DD_NameProject_1.Selected.Name_Project,
Code_Project: DD_NameProject_1.Selected.Code_Project,
Note: Text_Note_1.Text,
Start: DD_StartTime_1.Selected.Value,
End: DD_EndTime_1.Selected.Value,
User_Name: User().Email,
ModifiedOn_Date: Today()
});

 

Let me know if you dont understand or it doesnt work.

4 REPLIES 4
myke_deabreu
Level 8

Re: Update data with Patch and Lookup

Hi imaliasad,

 

What are you trying to lookup? 

imaliasad
Level: Powered On

Re: Update data with Patch and Lookup

Hi @myke_deabreu thank you for replying again. 

 

I have a column name ID_Timesheet, which I'd like to use with Lookup to update the record of that row. can I do that with Patch and Lookup, if yes would appreciate if you explain it to me

myke_deabreu
Level 8

Re: Update data with Patch and Lookup

I think I understand what you asking.

 

First assign the ID you want to update to a varible (e.g. Set(varname, the id you updating) 

 

Then you could do something like this:

 

Patch(
Table_SiteTimesheet,
First(Filter(Table_SiteTimesheet,ID_Timesheet=varname)),
{
Work_Date: Value(Date_WorkDate_1.SelectedDate),
Name_Project: DD_NameProject_1.Selected.Name_Project,
Code_Project: DD_NameProject_1.Selected.Code_Project,
Note: Text_Note_1.Text,
Start: DD_StartTime_1.Selected.Value,
End: DD_EndTime_1.Selected.Value,
User_Name: User().Email,
ModifiedOn_Date: Today()
});

 

Let me know if you dont understand or it doesnt work.

imaliasad
Level: Powered On

Re: Update data with Patch and Lookup

Thank you so much, this is exactly what I was looking for. Smiley Happy

Helpful resources

Announcements
firstImage

PowerApps Monthly Community Call!

Join us next Wednesday for our Demo Extravaganza, October 16, 2019 8am PDT.

firstImage

Microsoft Business Applications Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

SecondImage

Power Platform Summit North America

Register by September 5 to save $200

Top Kudoed Authors
Users Online
Currently online: 510 members 4,570 guests
Please welcome our newest community members: