web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / How do i update a reco...
Power Apps
Unanswered

How do i update a record that already exist in a SharePoint list, without creating a duplicate record?

(1) ShareShare
ReportReport
Posted on by 330

I have an app that is using a SharePoint list as a data source. I have a save button on a screen, and when I click save...I want to update an account if it already exists in the SharePoint list. Currently, my code is creating a duplicate entry. Here is what my logic looks like right now...

 

If(
	IsBlank(
 LookUp(
 MySPList,
 MyID = IDInput_1.Text
 )
 ),
			Collect(
				MySPList,
				{
					MyID: IDInput_1.Text,
					Title: AccountNameInput_1.Text,
					ClientName: ClientSelect_1.Selected.Name,
					ClientEmail: ClientEmailInput_1.Text,
					FirmID: FirmIDInput_1.Text,
					Strategy: StrategyInput_1.Selected.Value,
					SelectAttach: Attachments,
					Status: StatusDrpDwn.SelectedText,
					EmailContent: EmailBody_1.Text
				}
			),
			Patch(
				MySPList,
				LookUp(
					MySPList,
					MyID = IDInput_1.Text
				),
				{
					Title: AccountNameInput_1.Text,
					ClientName: ClientSelect_1.Selected.Name,
					ClientEmail: ClientEmailInput_1.Text,
					FirmID: FirmIDInput_1.Text,
					Strategy: StrategyInput_1.Selected.Value,
					SelectAttach: Attachments,
					Status: StatusDrpDwn.SelectedText,
					EmailContent: EmailBody_1.Text

				}
			)
);

 

How can I get this to just, 

1 - update the record that already exist, or

2 - create an entry if it does not exist already?

Categories:
  • Isa_Watanabe Profile Picture
    38 on at

    I am not sure why the creation of the collection was necessary, but here is how I'd do it.

    Basically it's: IF(Item Does Not Exists, Create Item in SharePoint, Otherwise Update Item in SharePoint)

     

    If(
    	IsBlank(LookUp(MySPList,MyID = IDInput_1.Text)),
    			Patch(
    				MySPList,
    				Defaults(MySPList),
    				{
    					Title: AccountNameInput_1.Text,
    					ClientName: ClientSelect_1.Selected.Name,
    					ClientEmail: ClientEmailInput_1.Text,
    					FirmID: FirmIDInput_1.Text,
    					Strategy: StrategyInput_1.Selected.Value,
    					SelectAttach: Attachments,
    					Status: StatusDrpDwn.SelectedText,
    					EmailContent: EmailBody_1.Text
    
    				}
    			),
     Patch(
    				MySPList,
    				LookUp(
    					MySPList,
    					MyID = IDInput_1.Text
    				),
    				{
    					Title: AccountNameInput_1.Text,
    					ClientName: ClientSelect_1.Selected.Name,
    					ClientEmail: ClientEmailInput_1.Text,
    					FirmID: FirmIDInput_1.Text,
    					Strategy: StrategyInput_1.Selected.Value,
    					SelectAttach: Attachments,
    					Status: StatusDrpDwn.SelectedText,
    					EmailContent: EmailBody_1.Text
    
    				}
    			)
    );. 

     

  • rebeccas Profile Picture
    2,591 on at

    If you can just do a form that is much better.

     

    You can make it go between New/Edit Form mode easily. Patch is slower and not near as reliable as using the Forms that were designed for PowerApps. 

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 411 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 338

#3
WarrenBelz Profile Picture

WarrenBelz 256 Most Valuable Professional

Last 30 days Overall leaderboard